add Match

pull/882/head
chanhengseang 2025-05-25 18:34:50 -07:00
parent e7b914c00b
commit 55f7ab3e21
7 changed files with 54 additions and 12 deletions

View File

@ -0,0 +1,8 @@
-- Create event_player join table for co-host players
CREATE TABLE event_co_host_player (
event_id BIGINT,
player_id BIGINT,
PRIMARY KEY (event_id, player_id),
CONSTRAINT fk_event_player_event FOREIGN KEY (event_id) REFERENCES event(id),
CONSTRAINT fk_event_player_player FOREIGN KEY (player_id) REFERENCES player(id)
);

View File

@ -29,6 +29,8 @@ import java.sql.Timestamp;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
@ -126,6 +128,12 @@ public class Event implements Serializable {
@Column(name = "`allow_wait_list`") @Column(name = "`allow_wait_list`")
private boolean allowWaitList; private boolean allowWaitList;
@ManyToMany
@JoinTable(name = "event_player",
joinColumns = {@JoinColumn(name = "event_id",referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "player_id",referencedColumnName = "id")})
private List<Player> coHostPlayers = new ArrayList<>();
public void copy(Event source){ public void copy(Event source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -23,8 +23,8 @@ public class Match implements Serializable {
private MatchGroup matchGroup; private MatchGroup matchGroup;
@ManyToOne @ManyToOne
@JoinColumn(name = "team_player_a_id") @JoinColumn(name = "team_a_id")
private TeamPlayer teamPlayerA; private TeamPlayer teamA;
@Column(name = "`score_a`") @Column(name = "`score_a`")
@ApiModelProperty(value = "Score A") @ApiModelProperty(value = "Score A")
@ -41,8 +41,8 @@ public class Match implements Serializable {
private boolean teamBWin; private boolean teamBWin;
@ManyToOne @ManyToOne
@JoinColumn(name = "team_player_b_id") @JoinColumn(name = "team_b_id")
private TeamPlayer teamPlayerB; private Team teamB;
@Column(name = "`score_verified`") @Column(name = "`score_verified`")
private boolean scoreVerified; private boolean scoreVerified;

View File

@ -6,6 +6,8 @@ import lombok.Setter;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Getter @Getter
@Setter @Setter
@ -25,4 +27,11 @@ public class MatchGroup implements Serializable {
@ManyToOne @ManyToOne
@JoinColumn(name = "event_id") @JoinColumn(name = "event_id")
private Event event; private Event event;
// how many teams in one group
@Column(name = "`group_team_size`")
private int groupTeamSize;
@OneToMany(mappedBy = "matchGroup")
private List<Team> teams = new ArrayList<>();
} }

View File

@ -16,6 +16,10 @@ public class Team implements Serializable {
@ApiModelProperty(value = "id", hidden = true) @ApiModelProperty(value = "id", hidden = true)
private Long id; private Long id;
@ManyToOne
@JoinColumn(name = "match_group_id")
private MatchGroup matchGroup;
@ManyToOne @ManyToOne
@JoinColumn(name = "event_id") @JoinColumn(name = "event_id")
private Event event; private Event event;

View File

@ -22,6 +22,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List;
/** /**
* @website https://eladmin.vip * @website https://eladmin.vip
@ -85,4 +86,7 @@ public class EventDto implements Serializable {
private boolean isPublic; private boolean isPublic;
private boolean allowWaitList; private boolean allowWaitList;
@ApiModelProperty(value = "Co-host players")
private List<PlayerDto> coHostPlayers;
} }

View File

@ -35,15 +35,24 @@ public class MatchDto implements Serializable {
@ApiModelProperty(value = "Match Group id") @ApiModelProperty(value = "Match Group id")
private Long matchGroupId; private Long matchGroupId;
@ApiModelProperty(value = "Team 1 id") @ApiModelProperty(value = "Team A id")
private Long team1Id; private Long teamA;
@ApiModelProperty(value = "Team 2 id") @ApiModelProperty(value = "Team B id")
private Long team2Id; private Long teamB;
@ApiModelProperty(value = "Score Team 1") @ApiModelProperty(value = "Score A")
private Integer scoreTeam1; private Integer scoreA;
@ApiModelProperty(value = "Score Team 2") @ApiModelProperty(value = "Score B")
private Integer scoreTeam2; private Integer scoreB;
@ApiModelProperty(value = "Team A Win")
private Boolean teamAWin;
@ApiModelProperty(value = "Team B Win")
private Boolean teamBWin;
@ApiModelProperty(value = "Score Verified")
private Boolean scoreVerified;
} }