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 41eaf794..a63844f9 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 @@ -2,3 +2,19 @@ alter table event add column status varchar(255), add column is_public bit default 0, add column allow_wait_list bit default 0; + +CREATE TABLE team ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + event_id BIGINT references event(id), + name VARCHAR(255), + team_size INT default 2 +); + +CREATE TABLE team_player ( + id BIGINT PRIMARY KEY AUTO_INCREMENT, + team_id BIGINT, + player_id BIGINT, + 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/Team.java b/sport/src/main/java/com/srr/domain/Team.java index 3b6b07a3..eec9db85 100644 --- a/sport/src/main/java/com/srr/domain/Team.java +++ b/sport/src/main/java/com/srr/domain/Team.java @@ -16,6 +16,10 @@ public class Team implements Serializable { @ApiModelProperty(value = "id", hidden = true) private Long id; + @ManyToOne + @JoinColumn(name = "event_id") + private Event event; + @Column(name = "`name`") @ApiModelProperty(value = "Name") private String name; @@ -25,8 +29,6 @@ public class Team implements Serializable { private int teamSize; @OneToMany(mappedBy = "team") - @JoinTable(name = "team_players", - joinColumns = {@JoinColumn(name = "team_id",referencedColumnName = "id")}) - @ApiModelProperty(value = "Players") - private List players; // + @ApiModelProperty(value = "teamPlayers") + private List teamPlayers; } diff --git a/sport/src/main/java/com/srr/dto/TeamDto.java b/sport/src/main/java/com/srr/dto/TeamDto.java new file mode 100644 index 00000000..b0af611d --- /dev/null +++ b/sport/src/main/java/com/srr/dto/TeamDto.java @@ -0,0 +1,47 @@ +/* +* 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; +import java.util.List; + +/** +* @website https://eladmin.vip +* @description / +* @author Chanheng +* @date 2025-05-25 +**/ +@Data +public class TeamDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Event") + private Long eventId; + + @ApiModelProperty(value = "Name") + private String name; + + @ApiModelProperty(value = "Team size") + private Integer teamSize; + + @ApiModelProperty(value = "Team players") + private List teamPlayers; +} diff --git a/sport/src/main/java/com/srr/dto/TeamPlayerDto.java b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java new file mode 100644 index 00000000..644821c3 --- /dev/null +++ b/sport/src/main/java/com/srr/dto/TeamPlayerDto.java @@ -0,0 +1,46 @@ +/* +* 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 TeamPlayerDto implements Serializable { + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "Team id") + private Long teamId; + + @ApiModelProperty(value = "Player id") + private Long playerId; + + @ApiModelProperty(value = "Player name") + private String playerName; + + @ApiModelProperty(value = "Is checked in") + private Boolean isCheckedIn; +} diff --git a/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java new file mode 100644 index 00000000..23ddc250 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.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.TeamPlayer; +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 TeamPlayerRepository extends JpaRepository, JpaSpecificationExecutor { +} diff --git a/sport/src/main/java/com/srr/repository/TeamRepository.java b/sport/src/main/java/com/srr/repository/TeamRepository.java new file mode 100644 index 00000000..a1f3f030 --- /dev/null +++ b/sport/src/main/java/com/srr/repository/TeamRepository.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.Team; +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 TeamRepository extends JpaRepository, JpaSpecificationExecutor { +}