add Match

pull/882/head
chanhengseang 2025-05-25 18:39:31 -07:00
parent 55f7ab3e21
commit 98b2cf54de
5 changed files with 96 additions and 13 deletions

View File

@ -1,8 +1,85 @@
-- Create event_player join table for co-host players
CREATE TABLE event_co_host_player (
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)
);
-- Create match_group table
CREATE TABLE match_group
(
id BIGINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255),
event_id BIGINT,
group_team_size INT DEFAULT 2,
CONSTRAINT fk_match_group_event FOREIGN KEY (event_id) REFERENCES event (id)
);
-- Create match table
CREATE TABLE ` match `
(
id
BIGINT
PRIMARY
KEY
AUTO_INCREMENT,
match_group_id
BIGINT,
team_a_id
BIGINT,
team_b_id
BIGINT,
score_a
INT
DEFAULT
0,
score_b
INT
DEFAULT
0,
team_a_win
BIT
DEFAULT
0,
team_b_win
BIT
DEFAULT
0,
score_verified
BIT
DEFAULT
0,
CONSTRAINT
fk_match_group
FOREIGN
KEY
(
match_group_id
) REFERENCES match_group
(
id
),
CONSTRAINT fk_team_a FOREIGN KEY
(
team_a_id
) REFERENCES team
(
id
),
CONSTRAINT fk_team_b FOREIGN KEY
(
team_b_id
) REFERENCES team
(
id
)
);
-- Add match_group_id column to team table
ALTER TABLE team
ADD COLUMN match_group_id BIGINT,
ADD CONSTRAINT fk_team_match_group FOREIGN KEY (match_group_id) REFERENCES match_group (id);

View File

@ -14,7 +14,7 @@ public class Match implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@Column(name = "id")
@ApiModelProperty(value = "id", hidden = true)
private Long id;
@ -24,26 +24,26 @@ public class Match implements Serializable {
@ManyToOne
@JoinColumn(name = "team_a_id")
private TeamPlayer teamA;
private Team teamA;
@Column(name = "`score_a`")
@Column(name = "score_a")
@ApiModelProperty(value = "Score A")
private int scoreA;
@Column(name = "`team_a_win`")
@Column(name = "team_a_win")
private boolean teamAWin;
@Column(name = "`score_b`")
@Column(name = "score_b")
@ApiModelProperty(value = "Score B")
private int scoreB;
@Column(name = "`team_b_win`")
@Column(name = "team_b_win")
private boolean teamBWin;
@ManyToOne
@JoinColumn(name = "team_b_id")
private Team teamB;
@Column(name = "`score_verified`")
@Column(name = "score_verified")
private boolean scoreVerified;
}

View File

@ -36,10 +36,10 @@ public class MatchDto implements Serializable {
private Long matchGroupId;
@ApiModelProperty(value = "Team A id")
private Long teamA;
private Long teamAId;
@ApiModelProperty(value = "Team B id")
private Long teamB;
private Long teamBId;
@ApiModelProperty(value = "Score A")
private Integer scoreA;

View File

@ -37,4 +37,7 @@ public class MatchGroupDto implements Serializable {
@ApiModelProperty(value = "Event id")
private Long eventId;
@ApiModelProperty(value = "Group team size")
private Integer groupTeamSize;
}

View File

@ -36,6 +36,9 @@ public class TeamDto implements Serializable {
@ApiModelProperty(value = "Event")
private Long eventId;
@ApiModelProperty(value = "Match Group")
private Long matchGroupId;
@ApiModelProperty(value = "Name")
private String name;