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 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> {
|
public interface UserRepository extends JpaRepository<StratsUser, String> {
|
||||||
Optional<StratsUser> findByGoogleUserId(String googleUserId);
|
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.AuthenticationRequest;
|
||||||
import me.akito123321.valoStrats.rest.requests.AuthenticationResponse;
|
import me.akito123321.valoStrats.rest.requests.AuthenticationResponse;
|
||||||
import me.akito123321.valoStrats.rest.util.JDBCUserDetailsService;
|
import me.akito123321.valoStrats.rest.util.JDBCUserDetailsService;
|
||||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/auth")
|
@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.GroupService;
|
||||||
import me.akito123321.valoStrats.rest.services.StratService;
|
import me.akito123321.valoStrats.rest.services.StratService;
|
||||||
import me.akito123321.valoStrats.rest.util.JDBCUserDetailsService;
|
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.Group;
|
||||||
import me.akito123321.valoStrats.schemas.Strat;
|
import me.akito123321.valoStrats.schemas.Strat;
|
||||||
|
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/group")
|
@RequestMapping("/api/group")
|
||||||
@ -155,7 +155,7 @@ public class GroupRestAPI {
|
|||||||
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
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);
|
groupService.saveGroup(group);
|
||||||
|
|
||||||
@ -208,7 +208,6 @@ 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.setLineups(newStrat.lineups());
|
|
||||||
|
|
||||||
stratService.saveStrat(strat);
|
stratService.saveStrat(strat);
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
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<byte[]> stratStates,
|
@NotNull List<StratState> stratStates) {
|
||||||
List<byte[]> lineups) {
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import jakarta.servlet.FilterChain;
|
|||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||||
|
|
||||||
public class AuthTokenFilter extends OncePerRequestFilter {
|
public class AuthTokenFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
import me.akito123321.valoStrats.db.repositories.UserRepository;
|
import me.akito123321.valoStrats.db.repositories.UserRepository;
|
||||||
|
import me.akito123321.valoStrats.schemas.StratsUser;
|
||||||
|
|
||||||
public class JDBCUserDetailsService implements UserDetailsService {
|
public class JDBCUserDetailsService implements UserDetailsService {
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import jakarta.persistence.GenerationType;
|
|||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
import me.akito123321.valoStrats.rest.util.StratsUser;
|
import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
@Entity(name = "wishlist_group")
|
@Entity(name = "wishlist_group")
|
||||||
public class Group {
|
public class Group {
|
||||||
@ -22,9 +22,15 @@ public class Group {
|
|||||||
private StratsUser owner;
|
private StratsUser owner;
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
private List<StratsUser> members;
|
private List<StratsUser> members;
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@OneToMany(fetch = FetchType.EAGER)
|
||||||
private List<Strat> strats;
|
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) {
|
public Group(String name, StratsUser owner) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.ElementCollection;
|
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;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Lob;
|
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Strat {
|
public class Strat {
|
||||||
@ -22,22 +21,20 @@ public class Strat {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Group group;
|
private Group group;
|
||||||
|
|
||||||
@Lob
|
|
||||||
@Column(length = Integer.MAX_VALUE)
|
|
||||||
@ElementCollection(fetch = FetchType.EAGER)
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
private List<byte[]> stratStates;
|
private List<StratState> stratStates;
|
||||||
|
|
||||||
@Lob
|
@OneToMany(fetch = FetchType.EAGER)
|
||||||
@Column(length = Integer.MAX_VALUE)
|
private List<PlayerType> playerTypes;
|
||||||
@ElementCollection(fetch = FetchType.EAGER)
|
|
||||||
private List<byte[]> lineups;
|
|
||||||
|
|
||||||
public Strat(String title, String description, Group group, List<byte[]> stratStates, List<byte[]> lineups) {
|
@ManyToOne
|
||||||
|
private Map map;
|
||||||
|
|
||||||
|
public Strat(String title, String description, Group group, List<StratState> stratStates) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this.stratStates = stratStates;
|
this.stratStates = stratStates;
|
||||||
this.lineups = lineups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Strat() {
|
public Strat() {
|
||||||
@ -64,20 +61,12 @@ public class Strat {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<byte[]> getStratStates() {
|
public List<StratState> getStratStates() {
|
||||||
return stratStates;
|
return stratStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStratStates(List<byte[]> stratStates) {
|
public void setStratStates(List<StratState> stratStates) {
|
||||||
this.stratStates = stratStates;
|
this.stratStates = stratStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<byte[]> getLineups() {
|
|
||||||
return lineups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLineups(List<byte[]> lineups) {
|
|
||||||
this.lineups = lineups;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -16,7 +16,6 @@ import jakarta.persistence.Entity;
|
|||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import me.akito123321.valoStrats.schemas.Group;
|
|
||||||
|
|
||||||
@Entity(name = "user")
|
@Entity(name = "user")
|
||||||
public class StratsUser implements UserDetails {
|
public class StratsUser implements UserDetails {
|
Loading…
Reference in New Issue
Block a user