diff --git a/eladmin-system/src/main/resources/db/migration/V8__add_match_and_event_player.sql b/eladmin-system/src/main/resources/db/migration/V8__add_match_and_event_player.sql index 83359e50..a8770977 100644 --- a/eladmin-system/src/main/resources/db/migration/V8__add_match_and_event_player.sql +++ b/eladmin-system/src/main/resources/db/migration/V8__add_match_and_event_player.sql @@ -1,8 +1,85 @@ -- Create event_player join table for co-host players -CREATE TABLE event_co_host_player ( - event_id BIGINT, +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) + 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); + diff --git a/sport/src/main/java/com/srr/domain/Match.java b/sport/src/main/java/com/srr/domain/Match.java index 5d8e192e..9dac810c 100644 --- a/sport/src/main/java/com/srr/domain/Match.java +++ b/sport/src/main/java/com/srr/domain/Match.java @@ -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; } diff --git a/sport/src/main/java/com/srr/dto/MatchDto.java b/sport/src/main/java/com/srr/dto/MatchDto.java index dfac82c2..db8babd5 100644 --- a/sport/src/main/java/com/srr/dto/MatchDto.java +++ b/sport/src/main/java/com/srr/dto/MatchDto.java @@ -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; diff --git a/sport/src/main/java/com/srr/dto/MatchGroupDto.java b/sport/src/main/java/com/srr/dto/MatchGroupDto.java index ac560961..05b0514e 100644 --- a/sport/src/main/java/com/srr/dto/MatchGroupDto.java +++ b/sport/src/main/java/com/srr/dto/MatchGroupDto.java @@ -37,4 +37,7 @@ public class MatchGroupDto implements Serializable { @ApiModelProperty(value = "Event id") private Long eventId; + + @ApiModelProperty(value = "Group team size") + private Integer groupTeamSize; } diff --git a/sport/src/main/java/com/srr/dto/TeamDto.java b/sport/src/main/java/com/srr/dto/TeamDto.java index b0af611d..b3850122 100644 --- a/sport/src/main/java/com/srr/dto/TeamDto.java +++ b/sport/src/main/java/com/srr/dto/TeamDto.java @@ -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;