1

Merge pull request #5 from ChUrl/REFACTOR-endpoint-mappings

Refactor endpoint mappings
This commit is contained in:
Christoph
2020-04-09 21:15:01 +02:00
committed by GitHub
14 changed files with 119 additions and 150 deletions

View File

@ -47,8 +47,8 @@ public class APIController {
@GetMapping("/update/{id}")
@Secured("ROLE_api_user")
@ApiOperation("Gibt veränderte Gruppen zurück")
public GroupRequestWrapper update(@ApiParam("Letzte gespeicherte EventId des Anfragestellers")
@PathVariable("id") long eventId) {
public GroupRequestWrapper getApiUpdate(@ApiParam("Letzte gespeicherte EventId des Anfragestellers")
@PathVariable("id") long eventId) {
return APIService.wrap(eventStoreService.findMaxEventId(),
projectionService.projectNewGroups(eventId));
@ -60,8 +60,8 @@ public class APIController {
@GetMapping("/usergroups/{id}")
@Secured("ROLE_api_user")
@ApiOperation("Gibt Gruppen zurück, in welchen ein Nutzer teilnimmt")
public List<String> usergroups(@ApiParam("Nutzer-Id")
@PathVariable("id") String userId) {
public List<String> getApiUserGroups(@ApiParam("Nutzer-Id")
@PathVariable("id") String userId) {
return IdService.uuidsToString(eventStoreService.findExistingUserGroups(new User(userId)));
}
@ -72,8 +72,8 @@ public class APIController {
@GetMapping("/group/{id}")
@Secured("ROLE_api_user")
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
public Group getGroupById(@ApiParam("Gruppen-Id der gefordeten Gruppe")
@PathVariable("id") String groupId) {
public Group getApiGroup(@ApiParam("Gruppen-Id der gefordeten Gruppe")
@PathVariable("id") String groupId) {
return projectionService.projectSingleGroup(UUID.fromString(groupId));
}

View File

@ -41,19 +41,17 @@ public class GroupCreationController {
this.projectionService = projectionService;
}
//TODO: /create/orga
@RolesAllowed("ROLE_orga")
@GetMapping("/createOrga")
public String getCreateOrgaPage(Model model) {
@GetMapping("/create/orga")
public String getCreateOrga(Model model) {
model.addAttribute("lectures", projectionService.projectLectures());
return "createOrga";
}
//TODO: /create/orga
@RolesAllowed("ROLE_orga")
@PostMapping("/createOrga")
@PostMapping("/create/orga")
@CacheEvict(value = "groups", allEntries = true)
public String postCreateOrga(KeycloakAuthenticationToken token,
@RequestParam("title") String title,
@ -79,19 +77,17 @@ public class GroupCreationController {
return "redirect:/gruppen2/details/" + IdService.uuidToString(group.getId());
}
//TODO: /create/student
@RolesAllowed("ROLE_studentin")
@GetMapping("/createStudent")
public String getCreateStudentPage(Model model) {
@GetMapping("/create/student")
public String getCreateStudent(Model model) {
model.addAttribute("lectures", projectionService.projectLectures());
return "createStudent";
}
//TODO: /create/student
@RolesAllowed("ROLE_studentin")
@PostMapping("/createStudent")
@PostMapping("/create/student")
@CacheEvict(value = "groups", allEntries = true)
public String postCreateStudent(KeycloakAuthenticationToken token,
@RequestParam("title") String title,

View File

@ -42,7 +42,6 @@ public class GroupDetailsController {
this.projectionService = projectionService;
}
//TODO: /details/{id}
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/details/{id}")
public String getDetailsPage(KeycloakAuthenticationToken token,
@ -74,12 +73,11 @@ public class GroupDetailsController {
return "detailsMember";
}
//TODO: /details/{id}/join
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/join")
@PostMapping("/details/{id}/join")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsJoin(KeycloakAuthenticationToken token,
@RequestParam("id") String groupId) {
@PathVariable("id") String groupId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -89,12 +87,11 @@ public class GroupDetailsController {
return "redirect:/gruppen2/details/" + groupId;
}
//TODO: /details/{id}/leave
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/leave")
@PostMapping("/details/{id}/leave")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsLeave(KeycloakAuthenticationToken token,
@RequestParam("group_id") String groupId) {
@PathVariable("id") String groupId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -104,12 +101,11 @@ public class GroupDetailsController {
return "redirect:/gruppen2";
}
//TODO: /details/{id}/destroy
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/delete")
@PostMapping("/details/{id}/destroy")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsDestroy(KeycloakAuthenticationToken token,
@RequestParam("group_id") String groupId) {
@PathVariable("id") String groupId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -119,9 +115,8 @@ public class GroupDetailsController {
return "redirect:/gruppen2";
}
//TODO: /details/{id}/meta
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/details/meta/{id}")
@GetMapping("/details/{id}/meta")
public String getDetailsMeta(KeycloakAuthenticationToken token,
Model model,
@PathVariable("id") String groupId) {
@ -136,14 +131,13 @@ public class GroupDetailsController {
return "changeMetadata";
}
//TODO: /details/{id}/meta/update
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/meta")
@PostMapping("/details/{id}/meta/update")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMetaUpdate(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@RequestParam("title") String title,
@RequestParam("description") String description,
@RequestParam("groupId") String groupId) {
@RequestParam("description") String description) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -154,9 +148,8 @@ public class GroupDetailsController {
return "redirect:/gruppen2/details/" + groupId;
}
//TODO: /details/{id}/members
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/details/members/{id}")
@GetMapping("/details/{id}/members")
public String getDetailsMembers(KeycloakAuthenticationToken token,
Model model,
@PathVariable("id") String groupId) {
@ -171,28 +164,26 @@ public class GroupDetailsController {
return "editMembers";
}
//TODO: /details/{id}/members/update/userlimit
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/members/setuserlimit")
@PostMapping("/details/{id}/members/update/userlimit")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateUserLimit(KeycloakAuthenticationToken token,
@RequestParam("maximum") long userLimit,
@RequestParam("group_id") String groupId) {
@PathVariable("id") String groupId,
@RequestParam("maximum") long userLimit) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
groupService.updateUserLimit(user, group, userLimit);
return "redirect:/gruppen2/details/members/" + groupId;
return "redirect:/gruppen2/details/" + groupId + "/members";
}
//TODO: /details/{id}/members/update/csv
@RolesAllowed("ROLE_orga")
@PostMapping("/details/members/csv")
@PostMapping("/details/{id}/members/update/csv")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateCsv(KeycloakAuthenticationToken token,
@RequestParam("group_id") String groupId,
@PathVariable("id") String groupId,
@RequestParam(value = "file", required = false) MultipartFile file) {
User user = new User(token);
@ -200,18 +191,17 @@ public class GroupDetailsController {
groupService.addUsersToGroup(CsvService.readCsvFile(file), group, user);
return "redirect:/gruppen2/details/members/" + groupId;
return "redirect:/gruppen2/details/" + groupId + "/members";
}
//TODO: Method + view for /details/{id}/members/{id}
//TODO: /details/{id}/members/{id}/update/role
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/members/togglerole")
@PostMapping("/details/{id}/members/{userid}/update/role")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateRole(KeycloakAuthenticationToken token,
@RequestParam("group_id") String groupId,
@RequestParam("user_id") String userId) {
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -225,16 +215,15 @@ public class GroupDetailsController {
return "redirect:/gruppen2/details/" + groupId;
}
return "redirect:/gruppen2/details/members/" + groupId;
return "redirect:/gruppen2/details/" + groupId + "/members";
}
//TODO: /details/{id}/members/{id}/delete
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/members/deleteuser")
@PostMapping("/details/{id}/members/{userid}/delete")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersDelete(KeycloakAuthenticationToken token,
@RequestParam("group_id") String groupId,
@RequestParam("user_id") String userId) {
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -246,6 +235,6 @@ public class GroupDetailsController {
groupService.deleteUser(new User(userId), group);
}
return "redirect:/gruppen2/details/members/" + groupId;
return "redirect:/gruppen2/details/" + groupId + "/members";
}
}

View File

@ -14,6 +14,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -38,22 +39,20 @@ public class SearchAndInviteController {
this.searchService = searchService;
}
//TODO: /search
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/searchPage")
public String getSearchPage(Model model) {
@GetMapping("/search")
public String getSearch(Model model) {
// Noch keine Suche gestartet: leeres Suchergebnis
model.addAttribute("gruppen", Collections.emptyList());
return "search";
}
//TODO: /search/{string}
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/search")
public String getSearch(KeycloakAuthenticationToken token,
Model model,
@RequestParam("suchbegriff") String search) {
@PostMapping("/search")
public String postSearch(KeycloakAuthenticationToken token,
Model model,
@RequestParam("string") String search) {
User user = new User(token);
List<Group> groups = searchService.searchPublicGroups(search, user);

View File

@ -24,13 +24,13 @@
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
<a href="/search" th:href="@{/gruppen2/search}">Suche</a>
</li>
</ul>
</nav>
@ -40,7 +40,7 @@
<div class="row">
<div class="col-10">
<h1>Metadaten ändern</h1>
<form method="post" th:action="@{/gruppen2/details/changeMetadata}">
<form method="post" th:action="@{/gruppen2/details/{id}/meta/update(id=${group.getId()})}">
<div class="shadow-sm p-2"
style=" border: 10px solid aliceblue; background: aliceblue;">
<div class="form-group">
@ -58,8 +58,6 @@
<button class="btn btn-primary"
style="background: #52a1eb; border-style: none;"
th:if="${group.getRoles().get(user.getId()) == admin}"
th:name="groupId"
th:value="${group.getId()}"
type="submit">Speichern
</button>
</div>

View File

@ -25,13 +25,13 @@
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
</li>
<li th:case="${true}" class="active">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}" class="active">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
<a th:href="@{/gruppen2/search}" href="/search">Suche</a>
</li>
</ul>
</nav>
@ -42,7 +42,7 @@
<div class="row">
<div class="col-10">
<h1>Gruppenerstellung</h1>
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/createOrga}">
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/create/orga}">
<div class="shadow-sm p-2" style=" border: 10px solid aliceblue; background: aliceblue;">
<div class="form-group">
<label for="titel">Titel</label>

View File

@ -21,13 +21,13 @@
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
</li>
<li th:case="${true}" class="active">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}" class="active">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
<a th:href="@{/gruppen2/search}" href="/search">Suche</a>
</li>
</ul>
</nav>
@ -37,7 +37,7 @@
<div class="row">
<div class="col-10">
<h1>Gruppenerstellung</h1>
<form method="post" th:action="@{/gruppen2/createStudent}">
<form method="post" th:action="@{/gruppen2/create/student}">
<div class="shadow-sm p-2"
style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue;">

View File

@ -18,13 +18,13 @@
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
<a href="/search" th:href="@{/gruppen2/search}">Suche</a>
</li>
</ul>
</nav>
@ -42,7 +42,7 @@
<div class="col-1">
<a class="fa fa-pencil"
style="font-size:30px; width: 5%;"
th:href="@{/gruppen2/details/changeMetadata/{id}(id=${group.getId()})}"
th:href="@{/gruppen2/details/{id}/meta(id=${group.getId()})}"
th:if="${group.getRoles().get(user.getId()) == admin}"></a>
</div>
</div>
@ -83,15 +83,14 @@
style="background: #52a1eb; border: none; margin: 5px;">
<a style="color: white;" th:href="@{/gruppen2}">Zurück</a>
</button>
<form method="post" th:action="@{/gruppen2/leaveGroup}">
<form method="post" th:action="@{/gruppen2/details/{id}/leave(id=${group.getId()})}">
<button class="btn btn-danger" style="border-style: none; margin: 5px;"
th:name="group_id" th:value="${group.getId()}"
th:name="group_id"
type="submit">Gruppe verlassen
</button>
</form>
<form method="post" th:action="@{/gruppen2/deleteGroup}">
<button class="btn btn-danger" style="border-style: none; margin: 5px;"
th:name="group_id" th:value="${group.getId()}"
<form method="post" th:action="@{/gruppen2/details/{id}/destroy(id=${group.getId()})}">
<button class="btn btn-danger" style="border-style: none; margin: 5px;" th:name="group_id"
th:if="${group.getRoles().get(user.getId()) == admin}"
type="submit">Gruppe löschen
</button>
@ -111,7 +110,7 @@
</div>
<div th:if="${group.getRoles().get(user.getId()) == admin}">
<form method="get"
th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
th:action="@{/gruppen2/details/{id}/members(id=${group.getId()})}">
<button class="btn btn-secondary" style="background: slategrey; float: left;">
Mitglieder bearbeiten
</button>

View File

@ -16,13 +16,13 @@
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li class="active">
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
<a th:href="@{/gruppen2/search}" href="/search">Suche</a>
</li>
</ul>
</nav>
@ -46,6 +46,10 @@
<p style="overflow-wrap: break-word; font-optical-sizing: auto;"
th:text="${group.getDescription()}"></p>
</div>
<form class="mt-3" th:if="${group.getVisibility() == public}" method="post"
th:action="@{/gruppen2/details/{id}/join(id=${group.getId()})}">
<button class="btn btn-primary" type="submit">Beitreten!</button>
</form>
</div>
</div>
</main>

View File

@ -21,13 +21,13 @@
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
<a th:href="@{/gruppen2/search}" href="/search">Suche</a>
</li>
</ul>
</nav>
@ -49,9 +49,8 @@
</div>
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue;">
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
<form th:action="@{/gruppen2/details/members/addUsersFromCsv}"
enctype="multipart/form-data"
method="post">
<form th:action="@{/gruppen2/details/{id}/members/update/csv(id=${group.getId()})}"
enctype="multipart/form-data" method="post">
<div class="input-group mb-3">
<div class="custom-file">
<input class="custom-file-input" id="file" th:name="file"
@ -63,8 +62,7 @@
<div class="input-group-append">
<button class="btn btn-outline-secondary"
style="background: #52a1eb; border-style: none;"
th:name="group_id" th:value="${group.getId()}"
type="submit">
th:name="group_id" type="submit">
<a style="color: white;">Hinzufügen</a>
</button>
</div>
@ -72,7 +70,7 @@
</form>
</div>
<div class="form-group pt-4">
<form method="post" th:action="@{/gruppen2/details/members/changeMaximum}">
<form method="post" th:action="@{/gruppen2/details/{id}/members/update/userlimit(id=${group.getId()})}">
<div class="input-group mb-3" id="userMaximum">
<label for="teilnehmerzahl"></label>
<input class="form-control"
@ -84,8 +82,7 @@
<div class="input-group-append">
<button class="btn btn-outline-secondary"
style="background: #52a1eb; border-style: none;"
th:name="group_id" th:value="${group.getId()}"
type="submit">
th:name="group_id" type="submit">
<a style="color: white;">Speichern</a>
</button>
</div>
@ -111,21 +108,13 @@
<td>
<div class="text-right btn-toolbar" style="float: right;" role="toolbar">
<form method="post"
th:action="@{/gruppen2/details/members/changeRole}">
<input th:name="group_id" th:value="${group.getId()}"
type="hidden">
<input th:name="user_id" th:value="${member.getId()}"
type="hidden">
th:action="@{/gruppen2/details/{id}/members/{userid}/update/role(id=${group.getId()}, userid=${member.getId()})}">
<button class="btn btn-warning btn-sm" type="submit"
style="margin: 5px;">Rolle ändern
</button>
</form>
<form method="post"
th:action="@{/gruppen2/details/members/deleteUser}">
<input th:name="group_id" th:value="${group.getId()}"
type="hidden">
<input th:name="user_id" th:value="${member.getId()}"
type="hidden">
th:action="@{/gruppen2/details/{id}/members/{userid}/delete(id=${group.getId()}, userid=${member.getId()})}">
<button class="btn btn-danger btn-sm" style="margin: 5px;"
th:if='!${account.getName().equals(member.getId())}'>
Mitglied entfernen

View File

@ -17,13 +17,13 @@
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li>
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
<a href="/search" th:href="@{/gruppen2/search}">Suche</a>
</li>
</ul>
</nav>

View File

@ -19,13 +19,13 @@
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li class="active">
<a href="/searchPage" th:href="@{/gruppen2/searchPage}">Suche</a>
<a href="/search" th:href="@{/gruppen2/search}">Suche</a>
</li>
</ul>
</nav>
@ -44,7 +44,7 @@
<div class="form-group mt-2" th:if="${group.getMembers().size() < group.getUserLimit()}">
<h3>Möchtest du dieser privaten Gruppe beitreten?</h3>
<div class="text-right">
<form method="post" th:action="@{/gruppen2/join}">
<form method="post" th:action="@{/gruppen2/details/{id}/join(id = ${group.getId()})}">
<input name="id" th:value="${group.getId()}" type="hidden"/>
<button class="btn btn-primary"
style="background: #52a1eb; border-style: none;"

View File

@ -17,13 +17,13 @@
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
</li>
<li th:case="${true}">
<a href="/createOrga" th:href="@{/gruppen2/createOrga}">Erstellen</a>
<a href="/create/orga" th:href="@{/gruppen2/create/orga}">Erstellen</a>
</li>
<li th:case="${false}">
<a href="/createStudent" th:href="@{/gruppen2/createStudent}">Erstellen</a>
<a href="/create/student" th:href="@{/gruppen2/create/student}">Erstellen</a>
</li>
<li class="active">
<a th:href="@{/gruppen2/searchPage}" href="/searchPage">Suche</a>
<a th:href="@{/gruppen2/search}" href="/search">Suche</a>
</li>
</ul>
</nav>
@ -35,20 +35,15 @@
<h1>Gruppensuche</h1>
<div class="shadow-sm p-2"
style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue;">
<form method="get" th:action="@{/gruppen2/search}">
<form method="post" th:action="@{/gruppen2/search}">
<div class="form-group">
<label for="suchleiste">Suchbegriff:</label>
<input class="form-control" id="suchleiste"
placeholder="z.B. Programmieren, Lerngruppe, ..."
th:name="suchbegriff" type="text">
th:name="string" type="text">
</div>
<button class="btn btn-primary"
style="background: #52a1eb; border-style: none;"
type="submit">Suchen
</button>
<button class="btn btn-primary" style="background: deepskyblue; border-style: none;" type="submit">
<a href="/gruppen2/search?suchbegriff=" style="color: white;">Alle
anzeigen</a>
<button class="btn btn-primary" style="background: #52a1eb; border-style: none;" type="submit">
Suchen
</button>
</form>
</div>

View File

@ -53,10 +53,10 @@ class APIControllerTest {
@Test
@WithMockUser(username = "api_user", roles = "api_user")
void updateGroup_noGroup() {
assertThat(apiController.update(0L).getGroupList()).hasSize(0);
assertThat(apiController.update(4L).getGroupList()).hasSize(0);
assertThat(apiController.update(10L).getGroupList()).hasSize(0);
assertThat(apiController.update(0L).getStatus()).isEqualTo(0);
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(0);
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(0);
assertThat(apiController.getApiUpdate(10L).getGroupList()).hasSize(0);
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(0);
}
@Test
@ -69,10 +69,10 @@ class APIControllerTest {
addUserEvent(uuidMock(0)),
addUserEvent(uuidMock(0)));
assertThat(apiController.update(0L).getGroupList()).hasSize(1);
assertThat(apiController.update(4L).getGroupList()).hasSize(1);
assertThat(apiController.update(10L).getGroupList()).hasSize(0);
assertThat(apiController.update(0L).getStatus()).isEqualTo(6);
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(1);
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(1);
assertThat(apiController.getApiUpdate(10L).getGroupList()).hasSize(0);
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(6);
}
@ -89,17 +89,17 @@ class APIControllerTest {
addUserEvent(uuidMock(1)),
addUserEvent(uuidMock(1)));
assertThat(apiController.update(0L).getGroupList()).hasSize(2);
assertThat(apiController.update(4L).getGroupList()).hasSize(1);
assertThat(apiController.update(6L).getGroupList()).hasSize(1);
assertThat(apiController.update(7L).getGroupList()).hasSize(1);
assertThat(apiController.update(0L).getStatus()).isEqualTo(9);
assertThat(apiController.getApiUpdate(0L).getGroupList()).hasSize(2);
assertThat(apiController.getApiUpdate(4L).getGroupList()).hasSize(1);
assertThat(apiController.getApiUpdate(6L).getGroupList()).hasSize(1);
assertThat(apiController.getApiUpdate(7L).getGroupList()).hasSize(1);
assertThat(apiController.getApiUpdate(0L).getStatus()).isEqualTo(9);
}
@Test
@WithMockUser(username = "api_user", roles = "api_user")
void getGroupsOfUser_noGroup() {
assertThat(apiController.usergroups("A")).isEmpty();
assertThat(apiController.getApiUserGroups("A")).isEmpty();
}
@Test
@ -110,7 +110,7 @@ class APIControllerTest {
createPrivateGroupEvent(uuidMock(2)),
addUserEvent(uuidMock(0), "A"));
assertThat(apiController.usergroups("A")).hasSize(1);
assertThat(apiController.getApiUserGroups("A")).hasSize(1);
}
@Test
@ -120,7 +120,7 @@ class APIControllerTest {
addUserEvent(uuidMock(0), "A"),
deleteUserEvent(uuidMock(0), "A"));
assertThat(apiController.usergroups("A")).isEmpty();
assertThat(apiController.getApiUserGroups("A")).isEmpty();
}
@Disabled
@ -131,7 +131,7 @@ class APIControllerTest {
addUserEvent(uuidMock(0), "A"),
deleteGroupEvent(uuidMock(0)));
assertThat(apiController.usergroups("A")).isEmpty();
assertThat(apiController.getApiUserGroups("A")).isEmpty();
}
@Test
@ -146,14 +146,14 @@ class APIControllerTest {
addUserEvent(uuidMock(2), "A"),
addUserEvent(uuidMock(2), "B"));
assertThat(apiController.usergroups("A")).hasSize(3);
assertThat(apiController.usergroups("B")).hasSize(2);
assertThat(apiController.getApiUserGroups("A")).hasSize(3);
assertThat(apiController.getApiUserGroups("B")).hasSize(2);
}
@Test
@WithMockUser(username = "api_user", roles = "api_user")
void getGroupFromId_noGroup() {
assertThrows(GroupNotFoundException.class, () -> apiController.getGroupById(uuidMock(0).toString()));
assertThrows(GroupNotFoundException.class, () -> apiController.getApiGroup(uuidMock(0).toString()));
}
@Test
@ -161,7 +161,7 @@ class APIControllerTest {
void getGroupFromId_singleGroup() {
eventStoreService.saveAll(createPrivateGroupEvent(uuidMock(0)));
assertThat(apiController.getGroupById(uuidMock(0).toString()).getId()).isEqualTo(uuidMock(0));
assertThat(apiController.getApiGroup(uuidMock(0).toString()).getId()).isEqualTo(uuidMock(0));
}
@Test
@ -171,6 +171,6 @@ class APIControllerTest {
updateGroupTitleEvent(uuidMock(0)),
deleteGroupEvent(uuidMock(0)));
assertThat(apiController.getGroupById(uuidMock(0).toString()).getTitle()).isEqualTo(null);
assertThat(apiController.getApiGroup(uuidMock(0).toString()).getTitle()).isEqualTo(null);
}
}