added strat-type endpoint and fixed profile schema
This commit is contained in:
parent
6d184ac0c6
commit
1521242653
@ -134,6 +134,47 @@ public class GroupRestAPI {
|
||||
return ResponseEntity.ok(group);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/strat-type")
|
||||
public ResponseEntity<Group> addStratType(@PathVariable String id, @RequestBody String typeName) {
|
||||
StratsUser user = getUser();
|
||||
|
||||
Group group = groupService.getGroupById(id);
|
||||
if (group == null) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
if (!group.getMembers().contains(user)) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
}
|
||||
if(group.getStratTypes().contains(typeName)) {
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).build();
|
||||
}
|
||||
|
||||
group.getStratTypes().add(typeName);
|
||||
|
||||
groupService.saveGroup(group);
|
||||
|
||||
return ResponseEntity.ok(group);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}/strat-type/{typeName}")
|
||||
public ResponseEntity<Group> removeStratType(@PathVariable String id, @PathVariable String typeName) {
|
||||
StratsUser user = getUser();
|
||||
|
||||
Group group = groupService.getGroupById(id);
|
||||
if (group == null | !group.getStratTypes().contains(typeName)) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
if (!group.getMembers().contains(user)) {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
}
|
||||
|
||||
group.getStratTypes().remove(typeName);
|
||||
|
||||
groupService.saveGroup(group);
|
||||
|
||||
return ResponseEntity.ok(group);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/member")
|
||||
public ResponseEntity<Group> addUserToGroup(@PathVariable String id, @RequestBody String userId) {
|
||||
StratsUser user = getUser();
|
||||
|
@ -18,6 +18,10 @@ public class Profile {
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private byte[] image;
|
||||
|
||||
public Profile() {
|
||||
|
||||
}
|
||||
|
||||
public Profile(String name, byte[] image) {
|
||||
super();
|
||||
this.name = name;
|
||||
|
Loading…
Reference in New Issue
Block a user