From e7b914c00bdeeea10b8c66e3305dfca548d94d3b Mon Sep 17 00:00:00 2001 From: chanhengseang Date: Sun, 25 May 2025 18:14:57 -0700 Subject: [PATCH] add Match --- .../db/migration/V7__add_event_status.sql | 1 + sport/src/main/java/com/srr/domain/Match.java | 49 +++++++++++++++++++ .../main/java/com/srr/domain/MatchGroup.java | 28 +++++++++++ .../main/java/com/srr/domain/TeamPlayer.java | 3 ++ sport/src/main/java/com/srr/dto/MatchDto.java | 49 +++++++++++++++++++ .../main/java/com/srr/dto/MatchGroupDto.java | 40 +++++++++++++++ .../main/java/com/srr/dto/TeamPlayerDto.java | 3 ++ .../srr/repository/MatchGroupRepository.java | 28 +++++++++++ .../com/srr/repository/MatchRepository.java | 28 +++++++++++ 9 files changed, 229 insertions(+) create mode 100644 sport/src/main/java/com/srr/domain/Match.java create mode 100644 sport/src/main/java/com/srr/domain/MatchGroup.java create mode 100644 sport/src/main/java/com/srr/dto/MatchDto.java create mode 100644 sport/src/main/java/com/srr/dto/MatchGroupDto.java create mode 100644 sport/src/main/java/com/srr/repository/MatchGroupRepository.java create mode 100644 sport/src/main/java/com/srr/repository/MatchRepository.java diff --git a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql index a63844f9..aa29a517 100644 --- a/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql +++ b/eladmin-system/src/main/resources/db/migration/V7__add_event_status.sql @@ -14,6 +14,7 @@ CREATE TABLE team_player ( id BIGINT PRIMARY KEY AUTO_INCREMENT, team_id BIGINT, player_id BIGINT, + score DOUBLE DEFAULT NULL, is_checked_in BIT DEFAULT 0, CONSTRAINT fk_team FOREIGN KEY (team_id) REFERENCES team(id), CONSTRAINT fk_player FOREIGN KEY (player_id) REFERENCES player(id) diff --git a/sport/src/main/java/com/srr/domain/Match.java b/sport/src/main/java/com/srr/domain/Match.java new file mode 100644 index 00000000..4054233a --- /dev/null +++ b/sport/src/main/java/com/srr/domain/Match.java @@ -0,0 +1,49 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Setter +@Getter +public class Match implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @ManyToOne + @JoinColumn(name = "match_group_id") + private MatchGroup matchGroup; + + @ManyToOne + @JoinColumn(name = "team_player_a_id") + private TeamPlayer teamPlayerA; + + @Column(name = "`score_a`") + @ApiModelProperty(value = "Score A") + private int scoreA; + + @Column(name = "`team_a_win`") + private boolean teamAWin; + + @Column(name = "`score_b`") + @ApiModelProperty(value = "Score B") + private int scoreB; + + @Column(name = "`team_b_win`") + private boolean teamBWin; + + @ManyToOne + @JoinColumn(name = "team_player_b_id") + private TeamPlayer teamPlayerB; + + @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 new file mode 100644 index 00000000..e538a2df --- /dev/null +++ b/sport/src/main/java/com/srr/domain/MatchGroup.java @@ -0,0 +1,28 @@ +package com.srr.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.io.Serializable; + +@Getter +@Setter +@Entity +public class MatchGroup implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id", hidden = true) + private Long id; + + @Column(name = "`name`") + @ApiModelProperty(value = "Name") + private String name; + + @ManyToOne + @JoinColumn(name = "event_id") + private Event event; +} diff --git a/sport/src/main/java/com/srr/domain/TeamPlayer.java b/sport/src/main/java/com/srr/domain/TeamPlayer.java index 1e09bb27..844173b1 100644 --- a/sport/src/main/java/com/srr/domain/TeamPlayer.java +++ b/sport/src/main/java/com/srr/domain/TeamPlayer.java @@ -22,6 +22,9 @@ public class TeamPlayer implements Serializable { @JoinColumn(name = "team_id") private Team team; + @Column(name = "`score`") + private Double score; + @ManyToOne @JoinColumn(name = "player_id") private Player player; diff --git a/sport/src/main/java/com/srr/dto/MatchDto.java b/sport/src/main/java/com/srr/dto/MatchDto.java new file mode 100644 index 00000000..232033b1 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/MatchDto.java @@ -0,0 +1,49 @@ +/* +* 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; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class MatchDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Match Group id") + private Long matchGroupId; + + @ApiModelProperty(value = "Team 1 id") + private Long team1Id; + + @ApiModelProperty(value = "Team 2 id") + private Long team2Id; + + @ApiModelProperty(value = "Score Team 1") + private Integer scoreTeam1; + + @ApiModelProperty(value = "Score Team 2") + private Integer scoreTeam2; +} diff --git a/sport/src/main/java/com/srr/dto/MatchGroupDto.java b/sport/src/main/java/com/srr/dto/MatchGroupDto.java new file mode 100644 index 00000000..ac560961 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/MatchGroupDto.java @@ -0,0 +1,40 @@ +/* +* 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; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class MatchGroupDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Name") + private String name; + + @ApiModelProperty(value = "Event id") + private Long eventId; +} diff --git a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java index 644821c3..c02c1666 100644 --- a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java +++ b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java @@ -41,6 +41,9 @@ public class TeamPlayerDto implements Serializable { @ApiModelProperty(value = "Player name") private String playerName; + @ApiModelProperty(value = "Score") + private Double score; + @ApiModelProperty(value = "Is checked in") private Boolean isCheckedIn; } diff --git a/sport/src/main/java/com/srr/repository/MatchGroupRepository.java b/sport/src/main/java/com/srr/repository/MatchGroupRepository.java new file mode 100644 index 00000000..f788ee89 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/MatchGroupRepository.java @@ -0,0 +1,28 @@ +/* +* 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.repository; + +import com.srr.domain.MatchGroup; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface MatchGroupRepository extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/sport/src/main/java/com/srr/repository/MatchRepository.java b/sport/src/main/java/com/srr/repository/MatchRepository.java new file mode 100644 index 00000000..51113f3f --- /dev/null +++ b/sport/src/main/java/com/srr/repository/MatchRepository.java @@ -0,0 +1,28 @@ +/* +* 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.repository; + +import com.srr.domain.Match; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author Chanheng +* @date 2025-05-25 +**/ +public interface MatchRepository extends JpaRepository, JpaSpecificationExecutor { +}