mirror of https://github.com/elunez/eladmin
build jar
parent
e8aee9751b
commit
004998166d
|
@ -49,5 +49,4 @@ public enum DataScopeEnum {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
45
pom.xml
45
pom.xml
|
@ -34,6 +34,7 @@
|
|||
<druid.version>1.2.19</druid.version>
|
||||
<commons-pool2.version>2.11.1</commons-pool2.version>
|
||||
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -160,7 +161,8 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- excel tool -->
|
||||
|
@ -241,6 +243,47 @@
|
|||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Configure Maven compiler plugin to properly handle Lombok -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Lombok plugin to ensure annotation processing -->
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<properties>
|
||||
<hutool.version>5.8.35</hutool.version>
|
||||
<mapstruct.version>1.5.3.Final</mapstruct.version>
|
||||
</properties>
|
||||
|
||||
<artifactId>sport</artifactId>
|
||||
|
@ -25,5 +26,49 @@
|
|||
<artifactId>eladmin-tools</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Explicitly add Lombok with provided scope -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Add build configuration specific to sport module -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-Amapstruct.defaultComponentModel=spring</arg>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -40,50 +40,50 @@ public class Club implements Serializable {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@Column(name = "name",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "Name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`description`")
|
||||
@Column(name = "description")
|
||||
@ApiModelProperty(value = "Description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
@ApiModelProperty(value = "Creation time", hidden = true)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@Column(name = "update_time")
|
||||
@UpdateTimestamp
|
||||
@ApiModelProperty(value = "Update time", hidden = true)
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`icon`")
|
||||
@Column(name = "icon")
|
||||
@ApiModelProperty(value = "Icon")
|
||||
private String icon;
|
||||
|
||||
@Column(name = "`sort`")
|
||||
@Column(name = "sort")
|
||||
@ApiModelProperty(value = "Sort")
|
||||
private Integer sort;
|
||||
|
||||
@Column(name = "`enabled`")
|
||||
@Column(name = "enabled")
|
||||
@ApiModelProperty(value = "Enabled")
|
||||
private Boolean enabled;
|
||||
|
||||
@Column(name = "`location`")
|
||||
@Column(name = "location")
|
||||
@ApiModelProperty(value = "Location")
|
||||
private String location;
|
||||
|
||||
@Column(name = "`longitude`")
|
||||
@Column(name = "longitude")
|
||||
@ApiModelProperty(value = "Longitude")
|
||||
private Double longitude;
|
||||
|
||||
@Column(name = "`latitude`")
|
||||
@Column(name = "latitude")
|
||||
@ApiModelProperty(value = "Latitude")
|
||||
private Double latitude;
|
||||
|
||||
|
|
|
@ -40,29 +40,29 @@ public class Court implements Serializable {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`club_id`")
|
||||
@Column(name = "club_id")
|
||||
@ApiModelProperty(value = "clubId")
|
||||
private Long clubId;
|
||||
|
||||
@Column(name = "`sport_id`")
|
||||
@Column(name = "sport_id")
|
||||
@ApiModelProperty(value = "sportId")
|
||||
private Long sportId;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
@ApiModelProperty(value = "Creation time", hidden = true)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@Column(name = "update_time")
|
||||
@UpdateTimestamp
|
||||
@ApiModelProperty(value = "Update time", hidden = true)
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`amount`",nullable = false)
|
||||
@Column(name = "amount",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "Amount")
|
||||
private Integer amount;
|
||||
|
|
|
@ -18,7 +18,8 @@ package com.srr.domain;
|
|||
import com.srr.converter.StringListConverter;
|
||||
import com.srr.enumeration.EventStatus;
|
||||
import com.srr.enumeration.Format;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
|
@ -41,7 +42,8 @@ import java.util.List;
|
|||
* @date 2025-05-18
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name="event")
|
||||
@SQLDelete(sql = "update event set status = 'DELETED' where id = ?", check = ResultCheckStyle.COUNT)
|
||||
@Where(clause = "status != 'DELETED'")
|
||||
|
@ -49,105 +51,105 @@ public class Event implements Serializable {
|
|||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@Column(name = "name", nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "Name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`description`")
|
||||
@Column(name = "description")
|
||||
@ApiModelProperty(value = "Description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "`format`",nullable = false)
|
||||
@Column(name = "format", nullable = false)
|
||||
@NotNull
|
||||
@Enumerated(EnumType.STRING)
|
||||
@ApiModelProperty(value = "SINGLE, DOUBLE")
|
||||
private Format format;
|
||||
|
||||
@Column(name = "`location`")
|
||||
@Column(name = "location")
|
||||
@ApiModelProperty(value = "Location")
|
||||
private String location;
|
||||
|
||||
@Column(name = "`image`")
|
||||
@Column(name = "image")
|
||||
@ApiModelProperty(value = "Image")
|
||||
private String image;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
@ApiModelProperty(value = "Creation time", hidden = true)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@Column(name = "update_time")
|
||||
@UpdateTimestamp
|
||||
@ApiModelProperty(value = "Update time", hidden = true)
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`check_in_at`")
|
||||
@Column(name = "check_in_at")
|
||||
@ApiModelProperty(value = "Check in time", hidden = true)
|
||||
private Timestamp checkInAt;
|
||||
|
||||
@Column(name = "`group_count`")
|
||||
@Column(name = "group_count")
|
||||
@ApiModelProperty(value = "Number of groups")
|
||||
private Integer groupCount;
|
||||
|
||||
@Column(name = "`sort`")
|
||||
@Column(name = "sort")
|
||||
@ApiModelProperty(value = "Sort")
|
||||
private Integer sort;
|
||||
|
||||
@Column(name = "`enabled`")
|
||||
@Column(name = "enabled")
|
||||
@ApiModelProperty(value = "Enabled")
|
||||
private Boolean enabled;
|
||||
|
||||
@Column(name = "`event_time`",nullable = false)
|
||||
@Column(name = "event_time", nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "Time")
|
||||
private Timestamp eventTime;
|
||||
|
||||
@Column(name = "`club_id`",nullable = false)
|
||||
@Column(name = "club_id", nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "clubId")
|
||||
private Long clubId;
|
||||
|
||||
@Column(name = "`public_link`")
|
||||
@Column(name = "public_link")
|
||||
@ApiModelProperty(value = "publicLink", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
|
||||
private String publicLink;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "`sport_id`",nullable = false)
|
||||
@Column(name = "sport_id", nullable = false)
|
||||
@ApiModelProperty(value = "sportId")
|
||||
private Long sportId;
|
||||
|
||||
@Column(name = "`create_by`")
|
||||
@Column(name = "create_by")
|
||||
@ApiModelProperty(value = "createBy")
|
||||
private Long createBy;
|
||||
|
||||
@Column(name = "`status`")
|
||||
@Column(name = "status")
|
||||
@Enumerated(EnumType.STRING)
|
||||
@ApiModelProperty(value = "status")
|
||||
private EventStatus status;
|
||||
|
||||
@Column(name = "`is_public`")
|
||||
@Column(name = "is_public")
|
||||
private boolean isPublic;
|
||||
|
||||
@Column(name = "`allow_wait_list`")
|
||||
@Column(name = "allow_wait_list")
|
||||
private boolean allowWaitList;
|
||||
|
||||
@Column(name = "`current_participants`")
|
||||
@Column(name = "current_participants")
|
||||
@ApiModelProperty(value = "Current number of participants")
|
||||
private Integer currentParticipants = 0;
|
||||
|
||||
@Column(name = "`max_participants`")
|
||||
@Column(name = "max_participants")
|
||||
@ApiModelProperty(value = "Maximum number of participants")
|
||||
private Integer maxParticipants;
|
||||
|
||||
@Column(name = "`poster_image`")
|
||||
@Column(name = "poster_image")
|
||||
private String posterImage;
|
||||
|
||||
@Column(name = "`tags`")
|
||||
@Column(name = "tags")
|
||||
@Convert(converter = StringListConverter.class)
|
||||
private List<String> tags = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -15,18 +15,19 @@
|
|||
*/
|
||||
package com.srr.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.annotations.*;
|
||||
import java.sql.Timestamp;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
@ -35,52 +36,53 @@ import java.io.Serializable;
|
|||
* @date 2025-05-18
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name="player")
|
||||
public class Player implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@Column(name = "name", nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "Name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`description`")
|
||||
@Column(name = "description")
|
||||
@ApiModelProperty(value = "Description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "`latitude`")
|
||||
@Column(name = "latitude")
|
||||
@ApiModelProperty(value = "Latitude")
|
||||
private Double latitude;
|
||||
|
||||
@Column(name = "`longitude`")
|
||||
@Column(name = "longitude")
|
||||
@ApiModelProperty(value = "Longitude")
|
||||
private Double longitude;
|
||||
|
||||
@Column(name = "`profile_image`")
|
||||
@Column(name = "profile_image")
|
||||
@ApiModelProperty(value = "Image")
|
||||
private String profileImage;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
@ApiModelProperty(value = "Creation time", hidden = true)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@Column(name = "update_time")
|
||||
@UpdateTimestamp
|
||||
@ApiModelProperty(value = "Update time", hidden = true)
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`rate_score`")
|
||||
@Column(name = "rate_score")
|
||||
@ApiModelProperty(value = "Score")
|
||||
private Double rateScore;
|
||||
|
||||
@Column(name = "`user_id`",nullable = false)
|
||||
@Column(name = "user_id", nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "userId")
|
||||
private Long userId;
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package com.srr.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "team")
|
||||
public class Team implements Serializable {
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ import java.io.Serializable;
|
|||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "`team_player`")
|
||||
@Table(name = "team_player")
|
||||
public class TeamPlayer implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@Column(name = "id")
|
||||
@ApiModelProperty(value = "id", hidden = true)
|
||||
private Long id;
|
||||
|
||||
|
@ -22,13 +22,13 @@ public class TeamPlayer implements Serializable {
|
|||
@JoinColumn(name = "team_id")
|
||||
private Team team;
|
||||
|
||||
@Column(name = "`score`")
|
||||
@Column(name = "score")
|
||||
private Double score;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "player_id")
|
||||
private Player player;
|
||||
|
||||
@Column(name = "`is_checked_in`")
|
||||
@Column(name = "is_checked_in")
|
||||
private boolean isCheckedIn;
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
* @date 2025-05-25
|
||||
**/
|
||||
public interface TeamPlayerRepository extends JpaRepository<TeamPlayer, Long>, JpaSpecificationExecutor<TeamPlayer> {
|
||||
boolean existsByTeamIdAndPlayerId(Long teamId, Long playerId);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,11 @@
|
|||
package com.srr.service.impl;
|
||||
|
||||
import com.srr.domain.Event;
|
||||
import com.srr.domain.Player;
|
||||
import com.srr.domain.Team;
|
||||
import com.srr.domain.TeamPlayer;
|
||||
import com.srr.enumeration.EventStatus;
|
||||
import com.srr.enumeration.Format;
|
||||
import me.zhengjie.exception.EntityNotFoundException;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
|
@ -104,7 +108,7 @@ public class EventServiceImpl implements EventService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public EventDto updateStatus(Long id, EventStatus status) {
|
||||
Event event = eventRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", id));
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", Long.valueOf(id)));
|
||||
|
||||
// Only update the status field
|
||||
event.setStatus(status);
|
||||
|
@ -121,7 +125,7 @@ public class EventServiceImpl implements EventService {
|
|||
public EventDto joinEvent(JoinEventDto joinEventDto) {
|
||||
// Find the event
|
||||
Event event = eventRepository.findById(joinEventDto.getEventId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", joinEventDto.getEventId()));
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", Long.valueOf(joinEventDto.getEventId())));
|
||||
|
||||
// Check if event allows joining
|
||||
if (event.getStatus() != EventStatus.OPEN) {
|
||||
|
@ -143,11 +147,75 @@ public class EventServiceImpl implements EventService {
|
|||
// Handle team-related logic
|
||||
if (joinEventDto.getTeamId() != null) {
|
||||
// Add player to existing team
|
||||
// For implementation, you'd use teamRepository and teamPlayerRepository
|
||||
// to check if team exists and add the player
|
||||
Team team = teamRepository.findById(joinEventDto.getTeamId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(Team.class, "id", Long.valueOf(joinEventDto.getTeamId())));
|
||||
|
||||
// Verify team belongs to this event
|
||||
if (!team.getEvent().getId().equals(event.getId())) {
|
||||
throw new BadRequestException("Team does not belong to this event");
|
||||
}
|
||||
|
||||
// Check if player is already in the team
|
||||
if (teamPlayerRepository.existsByTeamIdAndPlayerId(team.getId(), joinEventDto.getPlayerId())) {
|
||||
throw new BadRequestException("Player is already in this team");
|
||||
}
|
||||
|
||||
// Check if team is full
|
||||
if (team.getTeamSize() == team.getTeamPlayers().size()) {
|
||||
throw new BadRequestException("Team is already full");
|
||||
}
|
||||
|
||||
// Add player to team
|
||||
TeamPlayer teamPlayer = new TeamPlayer();
|
||||
teamPlayer.setTeam(team);
|
||||
Player player = new Player();
|
||||
player.setId(joinEventDto.getPlayerId());
|
||||
teamPlayer.setPlayer(player);
|
||||
teamPlayer.setCheckedIn(false);
|
||||
teamPlayerRepository.save(teamPlayer);
|
||||
} else {
|
||||
// Create new team for the player if needed
|
||||
// or add as individual participant depending on event format
|
||||
// Create new team for the player if needed or add as individual participant
|
||||
if (event.getFormat() == Format.SINGLE) {
|
||||
// For single format, create a "virtual" team with just one player
|
||||
Team team = new Team();
|
||||
team.setEvent(event);
|
||||
team.setName("Player " + joinEventDto.getPlayerId());
|
||||
team.setTeamSize(1);
|
||||
Team savedTeam = teamRepository.save(team);
|
||||
|
||||
// Add player to the team
|
||||
TeamPlayer teamPlayer = new TeamPlayer();
|
||||
teamPlayer.setTeam(savedTeam);
|
||||
Player player = new Player();
|
||||
player.setId(joinEventDto.getPlayerId());
|
||||
teamPlayer.setPlayer(player);
|
||||
teamPlayer.setCheckedIn(false);
|
||||
teamPlayerRepository.save(teamPlayer);
|
||||
} else if (event.getFormat() == Format.DOUBLE || event.getFormat() == Format.TEAM) {
|
||||
// For doubles/team format, create a new team
|
||||
Team team = new Team();
|
||||
team.setEvent(event);
|
||||
team.setName("New Team");
|
||||
|
||||
// Set team size based on format
|
||||
if (event.getFormat() == Format.DOUBLE) {
|
||||
team.setTeamSize(2);
|
||||
} else {
|
||||
// Default team size of 4 for TEAM format, can be adjusted as needed
|
||||
team.setTeamSize(4);
|
||||
}
|
||||
|
||||
Team savedTeam = teamRepository.save(team);
|
||||
|
||||
// Add player as the first member of the team
|
||||
TeamPlayer teamPlayer = new TeamPlayer();
|
||||
teamPlayer.setTeam(savedTeam);
|
||||
Player player = new Player();
|
||||
player.setId(joinEventDto.getPlayerId());
|
||||
teamPlayer.setPlayer(player);
|
||||
teamPlayer.setCheckedIn(false);
|
||||
teamPlayerRepository.save(teamPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
// Update participant count if not joining waitlist
|
||||
|
|
|
@ -56,7 +56,7 @@ public class WaitListServiceImpl implements WaitListService {
|
|||
public WaitListDto create(WaitList resources) {
|
||||
// Validate event exists
|
||||
Event event = eventRepository.findById(resources.getEventId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", resources.getEventId()));
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", Long.valueOf(resources.getEventId())));
|
||||
|
||||
// Check if player is already in wait list
|
||||
if (waitListRepository.findByEventIdAndPlayerId(resources.getEventId(), resources.getPlayerId()) != null) {
|
||||
|
@ -73,7 +73,7 @@ public class WaitListServiceImpl implements WaitListService {
|
|||
@Transactional
|
||||
public void update(WaitList resources) {
|
||||
WaitList waitList = waitListRepository.findById(resources.getId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", resources.getId()));
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", Long.valueOf(resources.getId())));
|
||||
waitList.copy(resources);
|
||||
waitListRepository.save(waitList);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class WaitListServiceImpl implements WaitListService {
|
|||
@Override
|
||||
public WaitListDto findById(Long id) {
|
||||
WaitList waitList = waitListRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", id));
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", Long.valueOf(id)));
|
||||
return mapToDto(waitList);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class WaitListServiceImpl implements WaitListService {
|
|||
public List<WaitListDto> findByEventId(Long eventId) {
|
||||
// Validate event exists
|
||||
if (!eventRepository.existsById(eventId)) {
|
||||
throw new EntityNotFoundException(Event.class, "id", eventId);
|
||||
throw new EntityNotFoundException(Event.class, "id", Long.valueOf(eventId));
|
||||
}
|
||||
|
||||
return waitListRepository.findByEventId(eventId).stream()
|
||||
|
@ -127,11 +127,11 @@ public class WaitListServiceImpl implements WaitListService {
|
|||
public boolean promoteToParticipant(Long waitListId) {
|
||||
// Find wait list entry
|
||||
WaitList waitList = waitListRepository.findById(waitListId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", waitListId));
|
||||
.orElseThrow(() -> new EntityNotFoundException(WaitList.class, "id", Long.valueOf(waitListId)));
|
||||
|
||||
// Find event
|
||||
Event event = eventRepository.findById(waitList.getEventId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", waitList.getEventId()));
|
||||
.orElseThrow(() -> new EntityNotFoundException(Event.class, "id", Long.valueOf(waitList.getEventId())));
|
||||
|
||||
// Check if event is full
|
||||
if (event.getCurrentParticipants() >= event.getMaxParticipants()) {
|
||||
|
|
Loading…
Reference in New Issue