even more data

This commit is contained in:
Akito123321 2024-06-15 19:21:08 +02:00
parent e82b3416d2
commit 31e61c6762
4 changed files with 57 additions and 4 deletions

View File

@ -9,7 +9,6 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -161,7 +160,14 @@ public class GroupRestAPI {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
} }
Strat strat = new Strat(stratRequest.title(), stratRequest.description(), group); Strat strat = new Strat(stratRequest.title(), stratRequest.description(), group, stratRequest.stratType());
if(stratRequest.attempts() != null) {
strat.setAttempts(stratRequest.attempts());
}
if(stratRequest.success() != null) {
strat.setSuccess(stratRequest.success());
}
stratService.saveStrat(strat); stratService.saveStrat(strat);
@ -220,6 +226,13 @@ public class GroupRestAPI {
strat.setDescription(newStrat.description()); strat.setDescription(newStrat.description());
strat.setTitle(newStrat.title()); strat.setTitle(newStrat.title());
strat.setStratStates(newStrat.stratStates()); strat.setStratStates(newStrat.stratStates());
strat.setStratType(newStrat.stratType());
if(newStrat.attempts() != null) {
strat.setAttempts(newStrat.attempts());
}
if(newStrat.success() != null) {
strat.setSuccess(newStrat.success());
}
stratService.saveStrat(strat); stratService.saveStrat(strat);

View File

@ -10,5 +10,8 @@ import me.akito123321.valoStrats.schemas.StratState;
public record StratRequest( public record StratRequest(
@Size(max = 50, message = "{title longer than 50 chars}") @NotBlank String title, @Size(max = 50, message = "{title longer than 50 chars}") @NotBlank String title,
@Size(max = 512, message = "{title longer than 50 chars}") @NotBlank String description, @Size(max = 512, message = "{title longer than 50 chars}") @NotBlank String description,
@NotNull List<StratState> stratStates) { @Size(max = 50, message = "{title longer than 50 chars}") @NotBlank String stratType,
@NotNull List<StratState> stratStates,
Integer attempts,
Integer success) {
} }

View File

@ -3,6 +3,7 @@ package me.akito123321.valoStrats.schemas;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
@ -30,6 +31,9 @@ public class Group {
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(fetch = FetchType.EAGER)
private List<Profile> profiles; private List<Profile> profiles;
@ElementCollection(fetch = FetchType.EAGER)
private List<String> stratTypes;
public Group(String name, StratsUser owner) { public Group(String name, StratsUser owner) {
this.name = name; this.name = name;
@ -38,6 +42,7 @@ public class Group {
this.strats = new ArrayList<Strat>(); this.strats = new ArrayList<Strat>();
this.maps = new ArrayList<Map>(); this.maps = new ArrayList<Map>();
this.profiles = new ArrayList<Profile>(); this.profiles = new ArrayList<Profile>();
this.stratTypes = new ArrayList<String>();
} }
public Group() { public Group() {
@ -68,4 +73,8 @@ public class Group {
this.name = name; this.name = name;
} }
public List<String> getStratTypes() {
return stratTypes;
}
} }

View File

@ -19,6 +19,9 @@ public class Strat {
private String id; private String id;
private String title; private String title;
private String description; private String description;
private String stratType;
private int attempts = 0, success = 0;
@ManyToOne @ManyToOne
private Group group; private Group group;
@ -31,10 +34,11 @@ public class Strat {
@ManyToOne @ManyToOne
private Map map; private Map map;
public Strat(String title, String description, Group group) { public Strat(String title, String description, Group group, String stratType) {
this.title = title; this.title = title;
this.description = description; this.description = description;
this.group = group; this.group = group;
this.stratType = stratType;
this.stratStates = new ArrayList<StratState>(); this.stratStates = new ArrayList<StratState>();
this.stratStates = new ArrayList<StratState>(); this.stratStates = new ArrayList<StratState>();
this.playerTypes = new ArrayList<PlayerType>(); this.playerTypes = new ArrayList<PlayerType>();
@ -72,4 +76,28 @@ public class Strat {
this.stratStates = stratStates; this.stratStates = stratStates;
} }
public String getStratType() {
return stratType;
}
public void setStratType(String stratType) {
this.stratType = stratType;
}
public int getAttempts() {
return attempts;
}
public void setAttempts(int attempts) {
this.attempts = attempts;
}
public int getSuccess() {
return success;
}
public void setSuccess(int success) {
this.success = success;
}
} }