Skip to content
Open
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,28 @@
package gg.agit.konect.domain.event.dto;

import java.util.List;

public record EventBoothMapResponse(
String mapImageUrl,
List<ZoneResponse> zones,
List<BoothMapItemResponse> booths
) {

public record ZoneResponse(
String code,
String label
) {
}

public record BoothMapItemResponse(
Integer boothId,
String name,
String zone,
Integer x,
Integer y,
Integer width,
Integer height,
String status
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gg.agit.konect.domain.event.enums;

public enum EventBoothMapItemStatus {
OPEN,
CLOSED,
HIDDEN
}
41 changes: 41 additions & 0 deletions src/main/java/gg/agit/konect/domain/event/model/EventBoothMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package gg.agit.konect.domain.event.model;

import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import gg.agit.konect.global.model.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "event_booth_map")
@NoArgsConstructor(access = PROTECTED)
public class EventBoothMap extends BaseEntity {

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", nullable = false, updatable = false, unique = true)
private Integer id;

@OneToOne(fetch = LAZY)
@JoinColumn(name = "event_id", nullable = false, updatable = false)
private Event event;

@Column(name = "map_image_url", length = 255)
private String mapImageUrl;

@Column(name = "width")
private Integer width;

@Column(name = "height")
private Integer height;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package gg.agit.konect.domain.event.model;

import static jakarta.persistence.EnumType.STRING;
import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import gg.agit.konect.domain.event.enums.EventBoothMapItemStatus;
import gg.agit.konect.global.model.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "event_booth_map_item")
@NoArgsConstructor(access = PROTECTED)
public class EventBoothMapItem extends BaseEntity {

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", nullable = false, updatable = false, unique = true)
private Integer id;

@ManyToOne(fetch = LAZY)
@JoinColumn(name = "event_booth_map_id", nullable = false, updatable = false)
private EventBoothMap eventBoothMap;

@OneToOne(fetch = LAZY)
@JoinColumn(name = "event_booth_id", nullable = false, updatable = false)
private EventBooth eventBooth;

@Column(name = "x", nullable = false)
private Integer x;

@Column(name = "y", nullable = false)
private Integer y;

@Column(name = "width", nullable = false)
private Integer width;

@Column(name = "height", nullable = false)
private Integer height;

@Enumerated(STRING)
@Column(name = "status", nullable = false, length = 20)
private EventBoothMapItemStatus status;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gg.agit.konect.domain.event.repository;

import java.util.List;

import org.springframework.data.repository.Repository;

import gg.agit.konect.domain.event.model.EventBoothMapItem;

public interface EventBoothMapItemRepository extends Repository<EventBoothMapItem, Integer> {

List<EventBoothMapItem> findAllByEventBoothMapIdOrderByIdAsc(Integer eventBoothMapId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gg.agit.konect.domain.event.repository;

import java.util.Optional;

import org.springframework.data.repository.Repository;

import gg.agit.konect.domain.event.model.EventBoothMap;

public interface EventBoothMapRepository extends Repository<EventBoothMap, Integer> {

Optional<EventBoothMap> findByEventId(Integer eventId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import gg.agit.konect.domain.event.dto.EventBoothMapResponse;
import gg.agit.konect.domain.event.dto.EventBoothSummaryResponse;
import gg.agit.konect.domain.event.dto.EventBoothsResponse;
import gg.agit.konect.domain.event.dto.EventProgramSummaryResponse;
import gg.agit.konect.domain.event.dto.EventProgramsResponse;
import gg.agit.konect.domain.event.enums.EventProgramType;
import gg.agit.konect.domain.event.model.EventBooth;
import gg.agit.konect.domain.event.model.EventBoothMap;
import gg.agit.konect.domain.event.model.EventBoothMapItem;
import gg.agit.konect.domain.event.model.EventProgram;
import gg.agit.konect.domain.event.repository.EventBoothMapItemRepository;
import gg.agit.konect.domain.event.repository.EventBoothMapRepository;
import gg.agit.konect.domain.event.repository.EventBoothRepository;
import gg.agit.konect.domain.event.repository.EventProgramRepository;
import gg.agit.konect.domain.event.repository.EventRepository;
Expand All @@ -28,6 +33,8 @@ public class EventService {
private final EventRepository eventRepository;
private final EventProgramRepository eventProgramRepository;
private final EventBoothRepository eventBoothRepository;
private final EventBoothMapRepository eventBoothMapRepository;
private final EventBoothMapItemRepository eventBoothMapItemRepository;

public EventProgramsResponse getEventPrograms(Integer eventId, EventProgramType type, Integer page, Integer limit,
Integer userId) {
Expand Down Expand Up @@ -77,6 +84,30 @@ public EventBoothsResponse getEventBooths(Integer eventId, String category, Stri
);
}

public EventBoothMapResponse getEventBoothMap(Integer eventId) {
EventBoothMap boothMap = eventBoothMapRepository.findByEventId(eventId)
.orElseThrow(() -> CustomException.of(NOT_FOUND_EVENT));

List<EventBoothMapItem> boothMapItems = eventBoothMapItemRepository.findAllByEventBoothMapIdOrderByIdAsc(
boothMap.getId());
List<EventBoothMapResponse.BoothMapItemResponse> booths = boothMapItems.stream()
.map(this::toEventBoothMapItemResponse)
.toList();

List<EventBoothMapResponse.ZoneResponse> zones = booths.stream()
.map(EventBoothMapResponse.BoothMapItemResponse::zone)
.filter(zone -> zone != null && !zone.isBlank())
.distinct()
.map(zone -> new EventBoothMapResponse.ZoneResponse(zone, zone))
.toList();

return new EventBoothMapResponse(
boothMap.getMapImageUrl(),
zones,
booths
);
}

private void getEvent(Integer eventId) {
eventRepository.findById(eventId)
.orElseThrow(() -> CustomException.of(NOT_FOUND_EVENT));
Expand Down Expand Up @@ -115,6 +146,21 @@ private EventBoothSummaryResponse toEventBoothSummaryResponse(EventBooth booth)
);
}

private EventBoothMapResponse.BoothMapItemResponse toEventBoothMapItemResponse(EventBoothMapItem boothMapItem) {
EventBooth booth = boothMapItem.getEventBooth();

return new EventBoothMapResponse.BoothMapItemResponse(
booth.getId(),
booth.getName(),
booth.getZone(),
boothMapItem.getX(),
boothMapItem.getY(),
boothMapItem.getWidth(),
boothMapItem.getHeight(),
boothMapItem.getStatus().name()
);
}

private record PagedResult<T>(List<T> items, int totalCount, int totalPage) {
}
}
32 changes: 32 additions & 0 deletions src/main/resources/db/migration/V70__add_event_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,35 @@ CREATE TABLE IF NOT EXISTS event_booth

FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS event_booth_map
(
id INT AUTO_INCREMENT PRIMARY KEY,
event_id INT NOT NULL,
map_image_url VARCHAR(255),
width INT,
height INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL,

FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE,
CONSTRAINT uq_event_booth_map_event_id UNIQUE (event_id)
);

CREATE TABLE IF NOT EXISTS event_booth_map_item
(
id INT AUTO_INCREMENT PRIMARY KEY,
event_booth_map_id INT NOT NULL,
event_booth_id INT NOT NULL,
x INT NOT NULL,
y INT NOT NULL,
width INT NOT NULL,
height INT NOT NULL,
status ENUM ('OPEN', 'CLOSED', 'HIDDEN') NOT NULL DEFAULT 'OPEN',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL,

FOREIGN KEY (event_booth_map_id) REFERENCES event_booth_map (id) ON DELETE CASCADE,
FOREIGN KEY (event_booth_id) REFERENCES event_booth (id) ON DELETE CASCADE,
CONSTRAINT uq_event_booth_map_item_booth_id UNIQUE (event_booth_id)
);
Loading