fix group endpoint
This commit is contained in:
parent
e71454f3d4
commit
6d184ac0c6
@ -71,6 +71,7 @@ public class GroupRestAPI {
|
||||
public ResponseEntity<Group> createGroup(@RequestBody GroupRequest request) {
|
||||
StratsUser user = getUser();
|
||||
Group group = new Group(request.name(), user);
|
||||
group.getMembers().add(user);
|
||||
groupService.saveGroup(group);
|
||||
return ResponseEntity.ok(group);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.akito123321.valoStrats.schemas;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@ -37,8 +38,7 @@ public class StratsUser implements UserDetails {
|
||||
private String googleUserId;
|
||||
private String displayName;
|
||||
|
||||
@ManyToMany(mappedBy = "members")
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@ManyToMany(mappedBy = "members", fetch = FetchType.EAGER)
|
||||
@JsonIgnore
|
||||
private List<Group> groups;
|
||||
|
||||
@ -111,4 +111,21 @@ public class StratsUser implements UserDetails {
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getUsername());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
StratsUser other = (StratsUser) obj;
|
||||
return Objects.equals(getUsername(), other.getUsername());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user