diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/enums/DataScopeEnum.java b/eladmin-common/src/main/java/me/zhengjie/utils/enums/DataScopeEnum.java index 08e41f66..b8556f34 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/enums/DataScopeEnum.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/enums/DataScopeEnum.java @@ -49,5 +49,4 @@ public enum DataScopeEnum { } return null; } - } diff --git a/pom.xml b/pom.xml index 2c0ce0c9..03eec6af 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ 1.2.19 2.11.1 1.4.2.Final + 1.18.30 @@ -160,7 +161,8 @@ org.projectlombok lombok - true + ${lombok.version} + provided @@ -241,6 +243,47 @@ true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + org.projectlombok + lombok + ${lombok.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + + -parameters + + + + + + + org.projectlombok + lombok-maven-plugin + 1.18.20.0 + + + generate-sources + + delombok + + + + diff --git a/sport/pom.xml b/sport/pom.xml index 845a1ebd..e2a388ef 100644 --- a/sport/pom.xml +++ b/sport/pom.xml @@ -8,6 +8,7 @@ 4.0.0 5.8.35 + 1.5.3.Final sport @@ -25,5 +26,49 @@ eladmin-tools 2.7 + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.mapstruct + mapstruct + ${mapstruct.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + org.projectlombok + lombok + ${lombok.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + + -Amapstruct.defaultComponentModel=spring + -parameters + + + + + \ No newline at end of file diff --git a/sport/src/main/java/com/srr/domain/Club.java b/sport/src/main/java/com/srr/domain/Club.java index c16214d3..71c4648a 100644 --- a/sport/src/main/java/com/srr/domain/Club.java +++ b/sport/src/main/java/com/srr/domain/Club.java @@ -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; diff --git a/sport/src/main/java/com/srr/domain/Court.java b/sport/src/main/java/com/srr/domain/Court.java index 68c22a7f..12109239 100644 --- a/sport/src/main/java/com/srr/domain/Court.java +++ b/sport/src/main/java/com/srr/domain/Court.java @@ -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; diff --git a/sport/src/main/java/com/srr/domain/Event.java b/sport/src/main/java/com/srr/domain/Event.java index 51fd4113..aa337cc8 100644 --- a/sport/src/main/java/com/srr/domain/Event.java +++ b/sport/src/main/java/com/srr/domain/Event.java @@ -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 tags = new ArrayList<>(); diff --git a/sport/src/main/java/com/srr/domain/Player.java b/sport/src/main/java/com/srr/domain/Player.java index 0d19614c..fdee5d99 100644 --- a/sport/src/main/java/com/srr/domain/Player.java +++ b/sport/src/main/java/com/srr/domain/Player.java @@ -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; diff --git a/sport/src/main/java/com/srr/domain/Team.java b/sport/src/main/java/com/srr/domain/Team.java index 79da5898..488fd593 100644 --- a/sport/src/main/java/com/srr/domain/Team.java +++ b/sport/src/main/java/com/srr/domain/Team.java @@ -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 { diff --git a/sport/src/main/java/com/srr/domain/TeamPlayer.java b/sport/src/main/java/com/srr/domain/TeamPlayer.java index 844173b1..88c6d1d7 100644 --- a/sport/src/main/java/com/srr/domain/TeamPlayer.java +++ b/sport/src/main/java/com/srr/domain/TeamPlayer.java @@ -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; } diff --git a/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java index 23ddc250..b833aeed 100644 --- a/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java +++ b/sport/src/main/java/com/srr/repository/TeamPlayerRepository.java @@ -25,4 +25,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @date 2025-05-25 **/ public interface TeamPlayerRepository extends JpaRepository, JpaSpecificationExecutor { + boolean existsByTeamIdAndPlayerId(Long teamId, Long playerId); } diff --git a/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java b/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java index 9473c08b..5793a08a 100644 --- a/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/EventServiceImpl.java @@ -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 diff --git a/sport/src/main/java/com/srr/service/impl/WaitListServiceImpl.java b/sport/src/main/java/com/srr/service/impl/WaitListServiceImpl.java index 14a1dd4d..c434d38c 100644 --- a/sport/src/main/java/com/srr/service/impl/WaitListServiceImpl.java +++ b/sport/src/main/java/com/srr/service/impl/WaitListServiceImpl.java @@ -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 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()) {