-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: #169 EventErrorCode -> BaseErrorCode Implements & 예외 처리 코드 리팩토링 * refactor: #169 계층간 DTO 분리를 위해 검색관련 DTO 객체 추가 처리 * refactor: #169 전반적인 코드 포맷팅 리팩토링 * feat: #169 Enum 클래스 예외처리 로직 추가
- Loading branch information
Showing
52 changed files
with
585 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
...i-event/src/main/java/com/pgms/apievent/eventHall/dto/request/EventHallCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package com.pgms.apievent.eventHall.dto.request; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
import java.util.List; | ||
|
||
public record EventHallCreateRequest(@NotBlank(message = "공연장 이름은 빈칸을 지정할 수 없습니다.") | ||
@Size(max = 25, message = "공연장 이름은 10자 이내로 입력해주세요.") String name, | ||
String address, | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests) { | ||
public record EventHallCreateRequest( | ||
@NotBlank(message = "공연장 이름은 빈칸을 지정할 수 없습니다.") | ||
@Size(max = 25, message = "공연장 이름은 10자 이내로 입력해주세요.") | ||
String name, | ||
String address, | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
...i-event/src/main/java/com/pgms/apievent/eventHall/dto/request/EventHallUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package com.pgms.apievent.eventHall.dto.request; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
import java.util.List; | ||
|
||
public record EventHallUpdateRequest(@NotBlank(message = "공연장 이름은 빈칸을 지정할 수 없습니다.") | ||
@Size(max = 25, message = "공연장 이름은 10자 이내로 입력해주세요.") String name, | ||
String address, | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests) { | ||
public record EventHallUpdateRequest( | ||
@NotBlank(message = "공연장 이름은 빈칸을 지정할 수 없습니다.") | ||
@Size(max = 25, message = "공연장 이름은 10자 이내로 입력해주세요.") | ||
String name, | ||
String address, | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests) { | ||
} |
28 changes: 17 additions & 11 deletions
28
api/api-event/src/main/java/com/pgms/apievent/eventHall/dto/response/EventHallResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package com.pgms.apievent.eventHall.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.pgms.coredomain.domain.event.EventHall; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record EventHallResponse(Long id, String name, String address, List<EventHallSeatResponse> eventHallSeatResponses) { | ||
static public EventHallResponse of(EventHall eventHall, List<EventHallSeatResponse> eventHallSeatResponses){ | ||
return EventHallResponse.builder() | ||
.id(eventHall.getId()) | ||
.name(eventHall.getName()) | ||
.address(eventHall.getAddress()) | ||
.eventHallSeatResponses(eventHallSeatResponses) | ||
.build(); | ||
} | ||
public record EventHallResponse( | ||
Long id, | ||
String name, | ||
String address, | ||
List<EventHallSeatResponse> eventHallSeatResponses) { | ||
|
||
public static EventHallResponse of(EventHall eventHall, List<EventHallSeatResponse> eventHallSeatResponses) { | ||
return EventHallResponse.builder() | ||
.id(eventHall.getId()) | ||
.name(eventHall.getName()) | ||
.address(eventHall.getAddress()) | ||
.eventHallSeatResponses(eventHallSeatResponses) | ||
.build(); | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
...i-event/src/main/java/com/pgms/apievent/eventHall/dto/response/EventHallSeatResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package com.pgms.apievent.eventHall.dto.response; | ||
|
||
import com.pgms.coredomain.domain.event.EventHallSeat; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record EventHallSeatResponse(Long id, String name) { | ||
static public EventHallSeatResponse of(EventHallSeat eventHallSeat){ | ||
return EventHallSeatResponse.builder() | ||
.id(eventHallSeat.getId()) | ||
.name(eventHallSeat.getName()) | ||
.build(); | ||
} | ||
|
||
public static EventHallSeatResponse of(EventHallSeat eventHallSeat) { | ||
return EventHallSeatResponse.builder() | ||
.id(eventHallSeat.getId()) | ||
.name(eventHallSeat.getName()) | ||
.build(); | ||
} | ||
} |
140 changes: 73 additions & 67 deletions
140
api/api-event/src/main/java/com/pgms/apievent/eventHall/service/EventHallService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,111 @@ | ||
package com.pgms.apievent.eventHall.service; | ||
|
||
import static com.pgms.apievent.exception.EventErrorCode.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.pgms.apievent.eventHall.dto.request.EventHallCreateRequest; | ||
import com.pgms.apievent.eventHall.dto.request.EventHallUpdateRequest; | ||
import com.pgms.apievent.eventHall.dto.request.EventHallSeatCreateRequest; | ||
import com.pgms.apievent.eventHall.dto.request.EventHallUpdateRequest; | ||
import com.pgms.apievent.eventHall.dto.response.EventHallResponse; | ||
import com.pgms.apievent.eventHall.dto.response.EventHallSeatResponse; | ||
import com.pgms.apievent.exception.EventHallNotFoundException; | ||
import com.pgms.apievent.exception.EventException; | ||
import com.pgms.coredomain.domain.event.EventHall; | ||
import com.pgms.coredomain.domain.event.EventHallEdit; | ||
import com.pgms.coredomain.domain.event.EventHallSeat; | ||
import com.pgms.coredomain.domain.event.repository.EventHallRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class EventHallService { | ||
|
||
private final EventHallRepository eventHallRepository; | ||
private final EventHallRepository eventHallRepository; | ||
|
||
public EventHallResponse createEventHall(EventHallCreateRequest eventHallCreateRequest) { | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests = eventHallCreateRequest.eventHallSeatCreateRequests(); | ||
public EventHallResponse createEventHall(EventHallCreateRequest eventHallCreateRequest) { | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests = eventHallCreateRequest.eventHallSeatCreateRequests(); | ||
|
||
List<EventHallSeat> eventHallSeats = eventHallSeatCreateRequests.stream() | ||
.map(this::createEventHallSeat) | ||
.toList(); | ||
List<EventHallSeat> eventHallSeats = eventHallSeatCreateRequests.stream() | ||
.map(this::createEventHallSeat) | ||
.toList(); | ||
|
||
EventHall eventHall = EventHall.builder() | ||
.name(eventHallCreateRequest.name()) | ||
.address(eventHallCreateRequest.address()) | ||
.eventHallSeats(eventHallSeats) | ||
.build(); | ||
EventHall eventHall = EventHall.builder() | ||
.name(eventHallCreateRequest.name()) | ||
.address(eventHallCreateRequest.address()) | ||
.eventHallSeats(eventHallSeats) | ||
.build(); | ||
|
||
EventHall savedEventHall = eventHallRepository.save(eventHall); | ||
EventHall savedEventHall = eventHallRepository.save(eventHall); | ||
|
||
List<EventHallSeatResponse> eventHallSeatResponses = savedEventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
List<EventHallSeatResponse> eventHallSeatResponses = savedEventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
|
||
return EventHallResponse.of(savedEventHall, eventHallSeatResponses); | ||
} | ||
return EventHallResponse.of(savedEventHall, eventHallSeatResponses); | ||
} | ||
|
||
public void deleteEventHall(Long id) { | ||
EventHall eventHall = eventHallRepository.findById(id) | ||
.orElseThrow(RuntimeException::new); | ||
public void deleteEventHall(Long id) { | ||
EventHall eventHall = eventHallRepository.findById(id) | ||
.orElseThrow(RuntimeException::new); | ||
|
||
eventHallRepository.delete(eventHall); | ||
} | ||
eventHallRepository.delete(eventHall); | ||
} | ||
|
||
public EventHallResponse updateEventHall(Long id, EventHallUpdateRequest eventHallUpdateRequest) { | ||
EventHall eventHall = eventHallRepository.findById(id).orElseThrow(EventHallNotFoundException::new); | ||
public EventHallResponse updateEventHall(Long id, EventHallUpdateRequest eventHallUpdateRequest) { | ||
EventHall eventHall = eventHallRepository.findById(id) | ||
.orElseThrow(() -> new EventException(EVENT_HALL_NOT_FOUND)); | ||
|
||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests = eventHallUpdateRequest.eventHallSeatCreateRequests(); | ||
List<EventHallSeatCreateRequest> eventHallSeatCreateRequests = eventHallUpdateRequest.eventHallSeatCreateRequests(); | ||
|
||
List<EventHallSeat> eventHallSeats = eventHallSeatCreateRequests.stream() | ||
.map(this::createEventHallSeat) | ||
.toList(); | ||
List<EventHallSeat> eventHallSeats = eventHallSeatCreateRequests.stream() | ||
.map(this::createEventHallSeat) | ||
.toList(); | ||
|
||
EventHallEdit eventHallEdit = EventHallEdit.builder() | ||
.name(eventHallUpdateRequest.name()) | ||
.address(eventHallUpdateRequest.address()) | ||
.eventHallSeats(eventHallSeats) | ||
.build(); | ||
EventHallEdit eventHallEdit = EventHallEdit.builder() | ||
.name(eventHallUpdateRequest.name()) | ||
.address(eventHallUpdateRequest.address()) | ||
.eventHallSeats(eventHallSeats) | ||
.build(); | ||
|
||
eventHall.updateEventHall(eventHallEdit); | ||
eventHall.updateEventHall(eventHallEdit); | ||
|
||
List<EventHallSeatResponse> eventHallSeatResponses = eventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
List<EventHallSeatResponse> eventHallSeatResponses = eventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
|
||
return EventHallResponse.of(eventHall, eventHallSeatResponses); | ||
} | ||
return EventHallResponse.of(eventHall, eventHallSeatResponses); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public EventHallResponse getEventHall(Long id) { | ||
EventHall eventHall = eventHallRepository.findById(id).orElseThrow(EventHallNotFoundException::new); | ||
@Transactional(readOnly = true) | ||
public EventHallResponse getEventHall(Long id) { | ||
EventHall eventHall = eventHallRepository.findById(id) | ||
.orElseThrow(() -> new EventException(EVENT_HALL_NOT_FOUND)); | ||
|
||
// TODO 못 읽어옴 | ||
List<EventHallSeatResponse> eventHallSeatResponses = eventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
// TODO 못 읽어옴 | ||
List<EventHallSeatResponse> eventHallSeatResponses = eventHall.getEventHallSeats() | ||
.stream() | ||
.map(EventHallSeatResponse::of) | ||
.toList(); | ||
|
||
return EventHallResponse.of(eventHall, eventHallSeatResponses); | ||
} | ||
return EventHallResponse.of(eventHall, eventHallSeatResponses); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<EventHallResponse> getEventHalls() { | ||
List<EventHall> eventHalls = eventHallRepository.findAll(); | ||
return eventHalls.stream() | ||
.map(eventHall -> EventHallResponse.of(eventHall, null)) | ||
.toList(); | ||
} | ||
@Transactional(readOnly = true) | ||
public List<EventHallResponse> getEventHalls() { | ||
List<EventHall> eventHalls = eventHallRepository.findAll(); | ||
return eventHalls.stream() | ||
.map(eventHall -> EventHallResponse.of(eventHall, null)) | ||
.toList(); | ||
} | ||
|
||
private EventHallSeat createEventHallSeat(EventHallSeatCreateRequest eventHallSeatCreateRequest) { | ||
return new EventHallSeat(eventHallSeatCreateRequest.name()); | ||
} | ||
private EventHallSeat createEventHallSeat(EventHallSeatCreateRequest eventHallSeatCreateRequest) { | ||
return new EventHallSeat(eventHallSeatCreateRequest.name()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.