Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.min.edu.booth.controller;

import java.util.List;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.min.edu.auth.dto.AuthenticatedMemberDto;
import com.min.edu.booth.domain.VenueMapType;
import com.min.edu.booth.dto.BoothMapPositionUpsertRequestDto;
import com.min.edu.booth.dto.VenueMapCreateRequestDto;
import com.min.edu.booth.dto.VenueMapResponseDto;
import com.min.edu.booth.service.VenueMapService;
import com.min.edu.common.response.ApiResponse;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class VenueMapController {

private final VenueMapService venueMapService;

@GetMapping("/events/{eventId}/venue-maps")
public ApiResponse<List<VenueMapResponseDto>> list(
@PathVariable Long eventId,
@AuthenticationPrincipal AuthenticatedMemberDto member) {
return ApiResponse.success(venueMapService.list(eventId, member));
}

// 공개 조회: 관람객/부스 모집 화면에서 게시된 평면도만 노출
@GetMapping("/events/{eventId}/venue-maps/public")
public ApiResponse<VenueMapResponseDto> getPublished(
@PathVariable Long eventId,
@RequestParam VenueMapType mapType) {
return ApiResponse.success(venueMapService.getPublished(eventId, mapType));
}

@PostMapping("/events/{eventId}/venue-maps")
public ApiResponse<VenueMapResponseDto> create(
@PathVariable Long eventId,
@Valid @RequestBody VenueMapCreateRequestDto request,
@AuthenticationPrincipal AuthenticatedMemberDto member) {
return ApiResponse.success(venueMapService.create(eventId, request, member));
}

@PatchMapping("/events/{eventId}/venue-maps/{mapId}/publish")
public ApiResponse<VenueMapResponseDto> publish(
@PathVariable Long eventId,
@PathVariable Long mapId,
@AuthenticationPrincipal AuthenticatedMemberDto member) {
return ApiResponse.success(venueMapService.publish(eventId, mapId, member));
}

@DeleteMapping("/events/{eventId}/venue-maps/{mapId}")
public ApiResponse<Void> delete(
@PathVariable Long eventId,
@PathVariable Long mapId,
@AuthenticationPrincipal AuthenticatedMemberDto member) {
venueMapService.delete(eventId, mapId, member);
return ApiResponse.success();
}

@PutMapping("/events/{eventId}/venue-maps/{mapId}/positions")
public ApiResponse<VenueMapResponseDto> upsertPositions(
@PathVariable Long eventId,
@PathVariable Long mapId,
@Valid @RequestBody BoothMapPositionUpsertRequestDto request,
@AuthenticationPrincipal AuthenticatedMemberDto member) {
return ApiResponse.success(venueMapService.upsertPositions(eventId, mapId, request, member));
}
}
11 changes: 11 additions & 0 deletions BE/src/main/java/com/min/edu/booth/domain/VenueMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,15 @@ public class VenueMap {

@Column(name = "updated_at", nullable = false)
private OffsetDateTime updatedAt;

public void publish(OffsetDateTime now) {
this.status = VenueMapStatus.PUBLISHED;
this.publishedAt = now;
this.updatedAt = now;
}

public void unpublish(OffsetDateTime now) {
this.status = VenueMapStatus.DRAFT;
this.updatedAt = now;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.min.edu.booth.dto;

import java.math.BigDecimal;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor
public class BoothMapPositionResponseDto {

private Long boothId;
private String boothCode;
private String displayName;
private BigDecimal xRatio;
private BigDecimal yRatio;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.min.edu.booth.dto;

import java.math.BigDecimal;
import java.util.List;

import jakarta.validation.Valid;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class BoothMapPositionUpsertRequestDto {

@NotEmpty
@Valid
private List<PositionItem> positions;

@Getter
@NoArgsConstructor
public static class PositionItem {

@NotNull
private Long boothId;

@NotNull
@DecimalMin(value = "0", inclusive = true)
@DecimalMax(value = "1", inclusive = true)
private BigDecimal xRatio;

@NotNull
@DecimalMin(value = "0", inclusive = true)
@DecimalMax(value = "1", inclusive = true)
private BigDecimal yRatio;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.min.edu.booth.dto;

import com.min.edu.booth.domain.VenueMapType;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;

import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class VenueMapCreateRequestDto {

@NotNull
private VenueMapType mapType;

@NotBlank
@Size(max = 50)
private String floorName;

@NotNull
private Long imageFileId;

@NotNull
@Positive
private Integer originalWidth;

@NotNull
@Positive
private Integer originalHeight;
}
29 changes: 29 additions & 0 deletions BE/src/main/java/com/min/edu/booth/dto/VenueMapResponseDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.min.edu.booth.dto;

import java.time.OffsetDateTime;
import java.util.List;

import com.min.edu.booth.domain.VenueMapStatus;
import com.min.edu.booth.domain.VenueMapType;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor
public class VenueMapResponseDto {

private Long id;
private Long eventId;
private VenueMapType mapType;
private String floorName;
private Long imageFileId;
private Integer originalWidth;
private Integer originalHeight;
private Integer version;
private VenueMapStatus status;
private OffsetDateTime publishedAt;
private List<BoothMapPositionResponseDto> positions;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.min.edu.booth.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import com.min.edu.booth.domain.BoothMapPosition;

public interface BoothMapPositionRepository extends JpaRepository<BoothMapPosition, Long> {

List<BoothMapPosition> findByVenueMapId(Long venueMapId);

void deleteByVenueMapId(Long venueMapId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.min.edu.booth.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import com.min.edu.booth.domain.VenueMap;
import com.min.edu.booth.domain.VenueMapStatus;
import com.min.edu.booth.domain.VenueMapType;

public interface VenueMapRepository extends JpaRepository<VenueMap, Long> {

List<VenueMap> findByEventIdOrderByFloorNameAscVersionDesc(Long eventId);

Optional<VenueMap> findByIdAndEventId(Long id, Long eventId);

Optional<VenueMap> findFirstByEventIdAndMapTypeAndFloorNameOrderByVersionDesc(
Long eventId, VenueMapType mapType, String floorName
);

Optional<VenueMap> findFirstByEventIdAndMapTypeAndStatusOrderByVersionDesc(
Long eventId, VenueMapType mapType, VenueMapStatus status
);

Optional<VenueMap> findFirstByEventIdAndMapTypeAndFloorNameAndStatus(
Long eventId, VenueMapType mapType, String floorName, VenueMapStatus status
);
}
Loading