@ -9,7 +9,7 @@ import lombok.Getter;
|
||||
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
||||
public class User {
|
||||
|
||||
private final String user_id;
|
||||
private final String id;
|
||||
private final String givenname;
|
||||
private final String familyname;
|
||||
private final String email;
|
||||
|
||||
@ -6,7 +6,7 @@ import mops.gruppen2.domain.Group;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Kombiniert den Status und die Gruppenliste zur ausgabe über die API
|
||||
* Kombiniert den Status und die Gruppenliste zur ausgabe über die API.
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class GroupRequestWrapper {
|
||||
|
||||
@ -4,6 +4,7 @@ import lombok.Value;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
@SuppressWarnings("checkstyle:membername")
|
||||
@Table("invite")
|
||||
@Value
|
||||
public class InviteLinkDTO {
|
||||
|
||||
@ -21,21 +21,22 @@ public class AddUserEvent extends Event {
|
||||
private String familyname;
|
||||
private String email;
|
||||
|
||||
public AddUserEvent(Long group_id, String user_id, String givenname, String familyname, String email) {
|
||||
super(group_id, user_id);
|
||||
public AddUserEvent(Long groupId, String userId, String givenname, String familyname, String email) {
|
||||
super(groupId, userId);
|
||||
this.givenname = givenname;
|
||||
this.familyname = familyname;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws EventException {
|
||||
User user = new User(this.user_id, this.givenname, this.familyname, this.email);
|
||||
User user = new User(this.userId, this.givenname, this.familyname, this.email);
|
||||
|
||||
if (group.getMembers().contains(user)) {
|
||||
throw new UserAlreadyExistsException("Der User existiert bereits");
|
||||
}
|
||||
|
||||
group.getMembers().add(user);
|
||||
group.getRoles().put(user_id, Role.MEMBER);
|
||||
group.getRoles().put(userId, Role.MEMBER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,15 +16,16 @@ public class CreateGroupEvent extends Event {
|
||||
private Long groupParent;
|
||||
private GroupType groupType;
|
||||
|
||||
public CreateGroupEvent(Long group_id, String user_id, Long parent, GroupType type, Visibility visibility) {
|
||||
super(group_id, user_id);
|
||||
public CreateGroupEvent(Long groupId, String userId, Long parent, GroupType type, Visibility visibility) {
|
||||
super(groupId, userId);
|
||||
this.groupParent = parent;
|
||||
this.groupType = type;
|
||||
this.groupVisibility = visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setId(this.group_id);
|
||||
group.setId(this.groupId);
|
||||
group.setParent(this.groupParent);
|
||||
group.setType(this.groupType);
|
||||
group.setVisibility(this.groupVisibility);
|
||||
|
||||
@ -8,8 +8,8 @@ import mops.gruppen2.domain.Group;
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class DeleteGroupEvent extends Event {
|
||||
|
||||
public DeleteGroupEvent(long group_id, String user_id) {
|
||||
super(group_id, user_id);
|
||||
public DeleteGroupEvent(Long groupId, String userId) {
|
||||
super(groupId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -14,15 +14,16 @@ import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
@NoArgsConstructor // For Jackson
|
||||
public class DeleteUserEvent extends Event {
|
||||
|
||||
public DeleteUserEvent(Long group_id, String user_id) {
|
||||
super(group_id, user_id);
|
||||
public DeleteUserEvent(Long groupId, String userId) {
|
||||
super(groupId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws EventException {
|
||||
for (User user : group.getMembers()) {
|
||||
if (user.getUser_id().equals(this.user_id)) {
|
||||
if (user.getId().equals(this.userId)) {
|
||||
group.getMembers().remove(user);
|
||||
group.getRoles().remove(user.getUser_id());
|
||||
group.getRoles().remove(user.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,8 +27,8 @@ import mops.gruppen2.domain.exception.EventException;
|
||||
@AllArgsConstructor
|
||||
public class Event {
|
||||
|
||||
protected Long group_id;
|
||||
protected String user_id;
|
||||
protected Long groupId;
|
||||
protected String userId;
|
||||
|
||||
public void apply(Group group) throws EventException {}
|
||||
}
|
||||
|
||||
@ -15,11 +15,12 @@ public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
||||
private String newGroupDescription;
|
||||
|
||||
public UpdateGroupDescriptionEvent(Long group_id, String user_id, String newGroupDescription) {
|
||||
super(group_id, user_id);
|
||||
public UpdateGroupDescriptionEvent(Long groupId, String userId, String newGroupDescription) {
|
||||
super(groupId, userId);
|
||||
this.newGroupDescription = newGroupDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setDescription(this.newGroupDescription);
|
||||
}
|
||||
|
||||
@ -15,11 +15,12 @@ public class UpdateGroupTitleEvent extends Event {
|
||||
|
||||
private String newGroupTitle;
|
||||
|
||||
public UpdateGroupTitleEvent(Long group_id, String user_id, String newGroupTitle) {
|
||||
super(group_id, user_id);
|
||||
public UpdateGroupTitleEvent(Long groupId, String userId, String newGroupTitle) {
|
||||
super(groupId, userId);
|
||||
this.newGroupTitle = newGroupTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) {
|
||||
group.setTitle(this.newGroupTitle);
|
||||
}
|
||||
|
||||
@ -17,16 +17,17 @@ public class UpdateRoleEvent extends Event {
|
||||
|
||||
private Role newRole;
|
||||
|
||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||
super(group_id, user_id);
|
||||
public UpdateRoleEvent(Long groupId, String userId, Role newRole) {
|
||||
super(groupId, userId);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Group group) throws UserNotFoundException {
|
||||
if (!group.getRoles().containsKey(user_id)) {
|
||||
if (!group.getRoles().containsKey(userId)) {
|
||||
throw new UserNotFoundException("Der User wurde nicht gefunden");
|
||||
}
|
||||
group.getRoles().put(this.user_id, this.newRole);
|
||||
group.getRoles().put(this.userId, this.newRole);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user