diff --git a/.windsurfrules b/.windsurfrules new file mode 100644 index 00000000..e69de29b diff --git a/eladmin-system/src/main/resources/db/migration/V6__add_event_link.sql b/eladmin-system/src/main/resources/db/migration/V6__add_event_link.sql index d9f94ef3..fd745c03 100644 --- a/eladmin-system/src/main/resources/db/migration/V6__add_event_link.sql +++ b/eladmin-system/src/main/resources/db/migration/V6__add_event_link.sql @@ -1,15 +1,6 @@ alter table event add column public_link varchar(255); -create table match_group -( - id bigint auto_increment primary key, - create_time datetime, - size int default 2 not null, - name varchar(255) not null, - score int default 0 -); - create table group_player ( id bigint auto_increment primary key, 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 new file mode 100644 index 00000000..f85a1dfa --- /dev/null +++ b/eladmin-system/src/main/resources/db/migration/V8__add_match_and_event_player.sql @@ -0,0 +1,41 @@ +-- 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) +); + +-- 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/Event.java b/sport/src/main/java/com/srr/domain/Event.java index 2a114ae0..5f8adf97 100644 --- a/sport/src/main/java/com/srr/domain/Event.java +++ b/sport/src/main/java/com/srr/domain/Event.java @@ -29,6 +29,8 @@ import java.sql.Timestamp; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * @website https://eladmin.vip @@ -126,6 +128,12 @@ public class Event implements Serializable { @Column(name = "`allow_wait_list`") private boolean allowWaitList; + @ManyToMany + @JoinTable(name = "event_co_host_player", + joinColumns = {@JoinColumn(name = "event_id",referencedColumnName = "id")}, + inverseJoinColumns = {@JoinColumn(name = "player_id",referencedColumnName = "id")}) + private List coHostPlayers = new ArrayList<>(); + public void copy(Event source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/sport/src/main/java/com/srr/domain/Match.java b/sport/src/main/java/com/srr/domain/Match.java index 4054233a..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; @@ -23,27 +23,27 @@ public class Match implements Serializable { private MatchGroup matchGroup; @ManyToOne - @JoinColumn(name = "team_player_a_id") - private TeamPlayer teamPlayerA; + @JoinColumn(name = "team_a_id") + 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_player_b_id") - private TeamPlayer teamPlayerB; + @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/domain/MatchGroup.java b/sport/src/main/java/com/srr/domain/MatchGroup.java index e538a2df..11ec1bc2 100644 --- a/sport/src/main/java/com/srr/domain/MatchGroup.java +++ b/sport/src/main/java/com/srr/domain/MatchGroup.java @@ -6,6 +6,8 @@ import lombok.Setter; import javax.persistence.*; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @Getter @Setter @@ -14,15 +16,22 @@ public class MatchGroup implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") + @Column(name = "id") @ApiModelProperty(value = "id", hidden = true) private Long id; - @Column(name = "`name`") + @Column(name = "name") @ApiModelProperty(value = "Name") private String name; @ManyToOne @JoinColumn(name = "event_id") private Event event; + + // how many teams in one group + @Column(name = "group_team_size") + private int groupTeamSize; + + @OneToMany(mappedBy = "matchGroup") + private List teams = new ArrayList<>(); } diff --git a/sport/src/main/java/com/srr/domain/Team.java b/sport/src/main/java/com/srr/domain/Team.java index eec9db85..79da5898 100644 --- a/sport/src/main/java/com/srr/domain/Team.java +++ b/sport/src/main/java/com/srr/domain/Team.java @@ -7,24 +7,28 @@ import java.io.Serializable; import java.util.List; @Entity -@Table(name = "`team`") +@Table(name = "team") public class Team implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") + @Column(name = "id") @ApiModelProperty(value = "id", hidden = true) private Long id; + @ManyToOne + @JoinColumn(name = "match_group_id") + private MatchGroup matchGroup; + @ManyToOne @JoinColumn(name = "event_id") private Event event; - @Column(name = "`name`") + @Column(name = "name") @ApiModelProperty(value = "Name") private String name; - @Column(name = "`team_size`") + @Column(name = "team_size") @ApiModelProperty(value = "Team size") private int teamSize; diff --git a/sport/src/main/java/com/srr/dto/EventDto.java b/sport/src/main/java/com/srr/dto/EventDto.java index b83aed93..6e58dc44 100644 --- a/sport/src/main/java/com/srr/dto/EventDto.java +++ b/sport/src/main/java/com/srr/dto/EventDto.java @@ -22,6 +22,7 @@ import lombok.Data; import java.io.Serializable; import java.sql.Timestamp; +import java.util.List; /** * @website https://eladmin.vip @@ -85,4 +86,7 @@ public class EventDto implements Serializable { private boolean isPublic; private boolean allowWaitList; + + @ApiModelProperty(value = "Co-host players") + private List coHostPlayers; } \ No newline at end of file diff --git a/sport/src/main/java/com/srr/dto/MatchDto.java b/sport/src/main/java/com/srr/dto/MatchDto.java index 232033b1..db8babd5 100644 --- a/sport/src/main/java/com/srr/dto/MatchDto.java +++ b/sport/src/main/java/com/srr/dto/MatchDto.java @@ -35,15 +35,24 @@ public class MatchDto implements Serializable { @ApiModelProperty(value = "Match Group id") private Long matchGroupId; - @ApiModelProperty(value = "Team 1 id") - private Long team1Id; + @ApiModelProperty(value = "Team A id") + private Long teamAId; - @ApiModelProperty(value = "Team 2 id") - private Long team2Id; + @ApiModelProperty(value = "Team B id") + private Long teamBId; - @ApiModelProperty(value = "Score Team 1") - private Integer scoreTeam1; + @ApiModelProperty(value = "Score A") + private Integer scoreA; - @ApiModelProperty(value = "Score Team 2") - private Integer scoreTeam2; + @ApiModelProperty(value = "Score B") + 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; } 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; diff --git a/sport/src/main/java/com/srr/dto/mapstruct/MatchGroupMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/MatchGroupMapper.java new file mode 100644 index 00000000..9160ff93 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/MatchGroupMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.MatchGroup; +import com.srr.dto.MatchGroupDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface MatchGroupMapper extends BaseMapper { + +} diff --git a/sport/src/main/java/com/srr/dto/mapstruct/MatchMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/MatchMapper.java new file mode 100644 index 00000000..b65d8c66 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/MatchMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.Match; +import com.srr.dto.MatchDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface MatchMapper extends BaseMapper { + +} diff --git a/sport/src/main/java/com/srr/dto/mapstruct/TeamMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/TeamMapper.java new file mode 100644 index 00000000..8f1deb9a --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/TeamMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.Team; +import com.srr.dto.TeamDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TeamMapper extends BaseMapper { + +} diff --git a/sport/src/main/java/com/srr/dto/mapstruct/TeamPlayerMapper.java b/sport/src/main/java/com/srr/dto/mapstruct/TeamPlayerMapper.java new file mode 100644 index 00000000..9ce07fd0 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/mapstruct/TeamPlayerMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2025 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package com.srr.dto.mapstruct; + +import me.zhengjie.base.BaseMapper; +import com.srr.domain.TeamPlayer; +import com.srr.dto.TeamPlayerDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TeamPlayerMapper extends BaseMapper { + +}