This commit is contained in:
Akito123321 2024-08-29 16:10:34 +02:00
parent 1521242653
commit 002ca575f2
13 changed files with 49 additions and 34 deletions

View File

@ -320,7 +320,7 @@ public class GroupRestAPI {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}
Map map = new Map(mapRequest.name(), mapRequest.image());
Map map = new Map(mapRequest.name(), mapRequest.image(), group);
mapService.saveMap(map);
@ -393,7 +393,7 @@ public class GroupRestAPI {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}
Profile profile = new Profile(profileRequest.name(), profileRequest.image());
Profile profile = new Profile(profileRequest.name(), profileRequest.image(), group);
profileService.saveProfile(profile);
@ -557,7 +557,7 @@ public class GroupRestAPI {
return ResponseEntity.badRequest().build();
}
Profile profile = new Profile(profileRequest.name(), profileRequest.image());
Profile profile = new Profile(profileRequest.name(), profileRequest.image(), group);
profileService.saveProfile(profile);

View File

@ -4,7 +4,7 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record GroupRequest(
@Size(max = 50, message = "{title longer than 50 chars}")
@Size(max = 50, message = "{name can not be longer than 50 chars}")
@NotBlank String name) {
}

View File

@ -4,5 +4,5 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record LineupRequest(
@Size(max = 50, message = "{name longer than 50 chars}") @NotBlank String description,
@Size(max = 512, message = "{description can not be longer than 512 chars}") @NotBlank String description,
byte[] image) {}

View File

@ -4,5 +4,5 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record MapRequest(
@Size(max = 50, message = "{name longer than 50 chars}") @NotBlank String name,
@Size(max = 50, message = "{name can not be longer than 50 chars}") @NotBlank String name,
byte[] image) {}

View File

@ -3,6 +3,6 @@ package me.akito123321.valoStrats.rest.requests;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record PlayerTypeRequest(@Size(max = 50, message = "{title longer than 50 chars}") @NotBlank String name,
@Size(max = 50, message = "{title longer than 50 chars}") @NotBlank String task) {
public record PlayerTypeRequest(@Size(max = 50, message = "{name can not be longer than 50 chars}") @NotBlank String name,
@Size(max = 512, message = "{task can not be longer than 512 chars}") @NotBlank String task) {
}

View File

@ -8,9 +8,9 @@ import jakarta.validation.constraints.Size;
import me.akito123321.valoStrats.schemas.StratState;
public record StratRequest(
@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 = 50, message = "{title longer than 50 chars}") @NotBlank String stratType,
@Size(max = 50, message = "{title can not be longer than 50 chars}") @NotBlank String title,
@Size(max = 512, message = "{description can not be longer than 50 chars}") @NotBlank String description,
@Size(max = 50, message = "{title stratType can not be than 50 chars}") @NotBlank String stratType,
@NotNull List<StratState> stratStates,
Integer attempts,
Integer success) {

View File

@ -4,6 +4,6 @@ import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record StratStateRequest (
@Size(max = 512, message = "{title longer than 50 chars}") @NotBlank String description,
@Size(max = 512, message = "{description can not be longer than 512 chars}") @NotBlank String description,
byte[] image) {
}

View File

@ -1,8 +1,11 @@
package me.akito123321.valoStrats.schemas;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import jakarta.persistence.CascadeType;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
@ -13,7 +16,7 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
@Entity(name = "wishlist_group")
@Entity(name = "strats_group")
public class Group {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
@ -22,27 +25,22 @@ public class Group {
@ManyToOne
private StratsUser owner;
@ManyToMany(fetch = FetchType.EAGER)
private List<StratsUser> members;
@OneToMany(fetch = FetchType.EAGER)
private List<Strat> strats;
private List<StratsUser> members = new ArrayList<StratsUser>();
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "group")
private List<Strat> strats = new ArrayList<Strat>();
@OneToMany(fetch = FetchType.EAGER)
private List<Map> maps;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "group")
private List<Map> maps = new ArrayList<Map>();
@ManyToMany(fetch = FetchType.EAGER)
private List<Profile> profiles;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "group")
private List<Profile> profiles = new ArrayList<Profile>();
@ElementCollection(fetch = FetchType.EAGER)
private List<String> stratTypes;
private Set<String> stratTypes = new HashSet<String>();
public Group(String name, StratsUser owner) {
this.name = name;
this.owner = owner;
this.members = new ArrayList<StratsUser>();
this.strats = new ArrayList<Strat>();
this.maps = new ArrayList<Map>();
this.profiles = new ArrayList<Profile>();
this.stratTypes = new ArrayList<String>();
}
public Group() {
@ -73,7 +71,7 @@ public class Group {
this.name = name;
}
public List<String> getStratTypes() {
public Set<String> getStratTypes() {
return stratTypes;
}

View File

@ -25,6 +25,10 @@ public class Lineup {
this.lineupImage = lineupImage;
}
public Lineup() {
}
public String getDescription() {
return description;
}

View File

@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
@Entity
public class Map {
@ -15,14 +16,22 @@ public class Map {
private String name;
@ManyToOne
private Group group;
@Lob
@Column(length = Integer.MAX_VALUE)
private byte[] image;
public Map(String name, byte[] image) {
public Map(String name, byte[] image, Group group) {
super();
this.name = name;
this.image = image;
this.group = group;
}
public Map() {
}
public String getName() {

View File

@ -3,6 +3,7 @@ package me.akito123321.valoStrats.schemas;
import java.util.ArrayList;
import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
@ -20,7 +21,7 @@ public class PlayerType {
private String task;
@ManyToMany(fetch = FetchType.EAGER)
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
private List<Profile> profiles;
public PlayerType(String name, String task) {

View File

@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
@Entity
public class Profile {
@ -14,6 +15,9 @@ public class Profile {
private String id;
private String name;
@ManyToOne
private Group group;
@Lob
@Column(length = Integer.MAX_VALUE)
private byte[] image;
@ -22,10 +26,11 @@ public class Profile {
}
public Profile(String name, byte[] image) {
public Profile(String name, byte[] image, Group group) {
super();
this.name = name;
this.image = image;
this.group = group;
}
public String getName() {

View File

@ -26,10 +26,10 @@ public class Strat {
private Group group;
@ElementCollection(fetch = FetchType.EAGER)
private List<StratState> stratStates;
private List<StratState> stratStates = new ArrayList<StratState>();
@OneToMany(fetch = FetchType.EAGER)
private List<PlayerType> playerTypes;
private List<PlayerType> playerTypes = new ArrayList<PlayerType>();
@ManyToOne
private Map map;
@ -39,8 +39,6 @@ public class Strat {
this.description = description;
this.group = group;
this.stratType = stratType;
this.stratStates = new ArrayList<StratState>();
this.playerTypes = new ArrayList<PlayerType>();
}
public Strat() {