1

add UserMaximum function

This commit is contained in:
tomvahl
2020-03-19 14:28:15 +01:00
parent 8291b5c41e
commit a2ae464bf0
8 changed files with 23 additions and 13 deletions

View File

@ -131,12 +131,13 @@ public class Gruppen2Controller {
@PostMapping("/createGroup") @PostMapping("/createGroup")
public String pCreateGroup(KeycloakAuthenticationToken token, public String pCreateGroup(KeycloakAuthenticationToken token,
@RequestParam("title") String title, @RequestParam("title") String title,
@RequestParam("beschreibung") String beschreibung, @RequestParam("description") String description,
@RequestParam(value = "visibility", required = false) Boolean visibility) throws EventException { @RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam("userMaximum") Long userMaximum) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
visibility = visibility == null; visibility = visibility == null;
controllerService.createGroup(account, title, beschreibung, visibility); controllerService.createGroup(account, title, description, visibility, userMaximum);
return "redirect:/gruppen2/"; return "redirect:/gruppen2/";
} }

View File

@ -20,6 +20,7 @@ public class Group {
private Long id; private Long id;
private String title; private String title;
private String description; private String description;
private Long userMaximum;
private GroupType type; private GroupType type;
private Visibility visibility; private Visibility visibility;
private Long parent; private Long parent;

View File

@ -15,12 +15,14 @@ public class CreateGroupEvent extends Event {
private Visibility groupVisibility; private Visibility groupVisibility;
private Long groupParent; private Long groupParent;
private GroupType groupType; private GroupType groupType;
private Long groupUserMaximum;
public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility) { public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility, Long userMaximum) {
super(groupId, userId); super(groupId, userId);
this.groupParent = parent; this.groupParent = parent;
this.groupType = type; this.groupType = type;
this.groupVisibility = visibility; this.groupVisibility = visibility;
this.groupUserMaximum = userMaximum;
} }
@Override @Override

View File

@ -43,7 +43,7 @@ public class ControllerService {
* @param title Gruppentitel * @param title Gruppentitel
* @param description Gruppenbeschreibung * @param description Gruppenbeschreibung
*/ */
public void createGroup(Account account, String title, String description, Boolean visibility) throws EventException { public void createGroup(Account account, String title, String description, Boolean visibility, Long userMaximum) throws EventException {
Visibility visibility1; Visibility visibility1;
Long groupId = eventService.checkGroup(); Long groupId = eventService.checkGroup();
@ -54,7 +54,7 @@ public class ControllerService {
createInviteLink(groupId); createInviteLink(groupId);
} }
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.SIMPLE, visibility1); CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.SIMPLE, visibility1, userMaximum);
eventService.saveEvent(createGroupEvent); eventService.saveEvent(createGroupEvent);
addUser(account, groupId); addUser(account, groupId);
@ -144,7 +144,7 @@ public class ControllerService {
visibility1 = Visibility.PRIVATE; visibility1 = Visibility.PRIVATE;
} }
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.LECTURE, visibility1); CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), null, GroupType.LECTURE, visibility1, null);
eventService.saveEvent(createGroupEvent); eventService.saveEvent(createGroupEvent);
addUser(account, groupId); addUser(account, groupId);

View File

@ -42,9 +42,14 @@
type="text"> type="text">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="beschreibung">Beschreibung</label> <label for="description">Beschreibung</label>
<textarea class="form-control" id="beschreibung" required <textarea class="form-control" id="description" required
rows="3" th:name="beschreibung"></textarea> rows="3" th:name="description"></textarea>
</div>
<div class="form-group mt-3">
<label for="userMaximum">Teilnehmeranzahl</label>
<input class="form-control" id="userMaximum" required th:name="userMaximum"
type="number" min="1">
</div> </div>
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input class="custom-control-input" id="visibility" th:name="visibility" <input class="custom-control-input" id="visibility" th:name="visibility"

View File

@ -56,7 +56,8 @@ public class EventBuilder {
faker.random().hex(), faker.random().hex(),
null, null,
GroupType.SIMPLE, GroupType.SIMPLE,
Visibility.PRIVATE Visibility.PRIVATE,
null
); );
} }

View File

@ -56,7 +56,7 @@ class EventServiceTest {
@Test @Test
void getDTOOffentlichTest() { void getDTOOffentlichTest() {
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null, GroupType.LECTURE, Visibility.PUBLIC); CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null, GroupType.LECTURE, Visibility.PUBLIC, null);
EventDTO eventDTO = eventService.getDTO(createGroupEvent); EventDTO eventDTO = eventService.getDTO(createGroupEvent);
assertTrue(eventDTO.isVisibility()); assertTrue(eventDTO.isVisibility());
} }

View File

@ -29,7 +29,7 @@ class GroupServiceTest {
@Test @Test
void rightClassForSuccessfulGroup() throws Exception { void rightClassForSuccessfulGroup() throws Exception {
List<Event> eventList = new ArrayList<>(); List<Event> eventList = new ArrayList<>();
eventList.add(new CreateGroupEvent(1L, "Prof", null, GroupType.LECTURE, Visibility.PRIVATE)); eventList.add(new CreateGroupEvent(1L, "Prof", null, GroupType.LECTURE, Visibility.PRIVATE,null));
eventList.add(new AddUserEvent(1L, "Ulli", "Ulli", "Honnis", "FC@B.de")); eventList.add(new AddUserEvent(1L, "Ulli", "Ulli", "Honnis", "FC@B.de"));
List<Group> groups = groupService.projectEventList(eventList); List<Group> groups = groupService.projectEventList(eventList);