more data 😈
This commit is contained in:
parent
440feffbd6
commit
ce800d2b46
@ -5,7 +5,7 @@ import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
||||
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||
|
||||
public interface UserRepository extends JpaRepository<StratsUser, String> {
|
||||
Optional<StratsUser> findByGoogleUserId(String googleUserId);
|
||||
|
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import me.akito123321.valoStrats.rest.requests.AuthenticationRequest;
|
||||
import me.akito123321.valoStrats.rest.requests.AuthenticationResponse;
|
||||
import me.akito123321.valoStrats.rest.util.JDBCUserDetailsService;
|
||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
||||
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
|
@ -22,9 +22,9 @@ import me.akito123321.valoStrats.rest.requests.StratRequest;
|
||||
import me.akito123321.valoStrats.rest.services.GroupService;
|
||||
import me.akito123321.valoStrats.rest.services.StratService;
|
||||
import me.akito123321.valoStrats.rest.util.JDBCUserDetailsService;
|
||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
||||
import me.akito123321.valoStrats.schemas.Group;
|
||||
import me.akito123321.valoStrats.schemas.Strat;
|
||||
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/group")
|
||||
@ -155,7 +155,7 @@ public class GroupRestAPI {
|
||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
}
|
||||
|
||||
group.getStrats().add(new Strat(strat.title(), strat.description(), group, strat.stratStates(), strat.lineups()));
|
||||
group.getStrats().add(new Strat(strat.title(), strat.description(), group, strat.stratStates()));
|
||||
|
||||
groupService.saveGroup(group);
|
||||
|
||||
@ -208,7 +208,6 @@ public class GroupRestAPI {
|
||||
strat.setDescription(newStrat.description());
|
||||
strat.setTitle(newStrat.title());
|
||||
strat.setStratStates(newStrat.stratStates());
|
||||
strat.setLineups(newStrat.lineups());
|
||||
|
||||
stratService.saveStrat(strat);
|
||||
|
||||
|
@ -5,10 +5,10 @@ import java.util.List;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
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,
|
||||
@NotNull List<byte[]> stratStates,
|
||||
List<byte[]> lineups) {
|
||||
@NotNull List<StratState> stratStates) {
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||
|
||||
public class AuthTokenFilter extends OncePerRequestFilter {
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
import me.akito123321.valoStrats.db.repositories.UserRepository;
|
||||
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||
|
||||
public class JDBCUserDetailsService implements UserDetailsService {
|
||||
|
||||
|
@ -10,7 +10,7 @@ import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
@Entity(name = "wishlist_group")
|
||||
public class Group {
|
||||
@ -22,8 +22,14 @@ public class Group {
|
||||
private StratsUser owner;
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
private List<StratsUser> members;
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
private List<Strat> strats;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
private List<Map> maps;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
private List<Profile> profiles;
|
||||
|
||||
public Group(String name, StratsUser owner) {
|
||||
this.name = name;
|
||||
|
48
src/main/java/me/akito123321/valoStrats/schemas/Lineup.java
Normal file
48
src/main/java/me/akito123321/valoStrats/schemas/Lineup.java
Normal file
@ -0,0 +1,48 @@
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class Lineup {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
private String description;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private byte[] lineupImage;
|
||||
|
||||
public Lineup(String description, byte[] lineupImage) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.lineupImage = lineupImage;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public byte[] getLineupImage() {
|
||||
return lineupImage;
|
||||
}
|
||||
|
||||
public void setLineupImage(byte[] lineupImage) {
|
||||
this.lineupImage = lineupImage;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
48
src/main/java/me/akito123321/valoStrats/schemas/Map.java
Normal file
48
src/main/java/me/akito123321/valoStrats/schemas/Map.java
Normal file
@ -0,0 +1,48 @@
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class Map {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private byte[] image;
|
||||
|
||||
public Map(String name, byte[] image) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte[] getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(byte[] image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
@Entity
|
||||
public class PlayerType {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String task;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
private List<Profile> profiles;
|
||||
|
||||
public PlayerType(String name, List<Profile> profiles, String task) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.profiles = profiles;
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Profile> getProfiles() {
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public void setProfiles(List<Profile> profiles) {
|
||||
this.profiles = profiles;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setTask(String task) {
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
}
|
47
src/main/java/me/akito123321/valoStrats/schemas/Profile.java
Normal file
47
src/main/java/me/akito123321/valoStrats/schemas/Profile.java
Normal file
@ -0,0 +1,47 @@
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class Profile {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
private byte[] image;
|
||||
|
||||
public Profile(String name, byte[] image) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte[] getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(byte[] image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
@ -2,15 +2,14 @@ package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
public class Strat {
|
||||
@ -22,22 +21,20 @@ public class Strat {
|
||||
@ManyToOne
|
||||
private Group group;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
private List<byte[]> stratStates;
|
||||
private List<StratState> stratStates;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
private List<byte[]> lineups;
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
private List<PlayerType> playerTypes;
|
||||
|
||||
@ManyToOne
|
||||
private Map map;
|
||||
|
||||
public Strat(String title, String description, Group group, List<byte[]> stratStates, List<byte[]> lineups) {
|
||||
public Strat(String title, String description, Group group, List<StratState> stratStates) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.group = group;
|
||||
this.stratStates = stratStates;
|
||||
this.lineups = lineups;
|
||||
}
|
||||
|
||||
public Strat() {
|
||||
@ -64,20 +61,12 @@ public class Strat {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<byte[]> getStratStates() {
|
||||
public List<StratState> getStratStates() {
|
||||
return stratStates;
|
||||
}
|
||||
|
||||
public void setStratStates(List<byte[]> stratStates) {
|
||||
this.stratStates = stratStates;
|
||||
}
|
||||
|
||||
public List<byte[]> getLineups() {
|
||||
return lineups;
|
||||
}
|
||||
|
||||
public void setLineups(List<byte[]> lineups) {
|
||||
this.lineups = lineups;
|
||||
|
||||
public void setStratStates(List<StratState> stratStates) {
|
||||
this.stratStates = stratStates;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class StratState {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
private String description;
|
||||
|
||||
@ManyToOne
|
||||
private Strat strat;
|
||||
|
||||
@Lob
|
||||
@Column(length = Integer.MAX_VALUE)
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
private List<Lineup> lineups;
|
||||
|
||||
public StratState(String description, Strat strat, List<Lineup> lineups) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.strat = strat;
|
||||
this.lineups = lineups;
|
||||
}
|
||||
|
||||
public StratState() {
|
||||
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Strat getStrat() {
|
||||
return strat;
|
||||
}
|
||||
|
||||
public List<Lineup> getLineups() {
|
||||
return lineups;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.akito123321.valoStrats.rest.util;
|
||||
package me.akito123321.valoStrats.schemas;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -16,7 +16,6 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import me.akito123321.valoStrats.schemas.Group;
|
||||
|
||||
@Entity(name = "user")
|
||||
public class StratsUser implements UserDetails {
|
Loading…
Reference in New Issue
Block a user