Skip to content
Merged
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
Expand Up @@ -5,11 +5,13 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;


public record CreateConcertReq (
@NotBlank(message = "콘서트 이름은 비어 있을 수 없습니다.")
@Size(min = 1, max = 20, message = "공연장 이름은 1자 이상 20자 이하이어야 합니다.")
String concertName,

@Positive(message = "런타임은 양수여야 합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;

public record CreateStageReq(
@NotBlank(message = "공연장 이름은 비어 있을 수 없습니다.")
@Size(min = 1, max = 20, message = "공연장 이름은 1자 이상 30자 이하이어야 합니다.")
String name,

@NotBlank(message = "위치는 비어 있을 수 없습니다.")
@Size(min = 1, max = 30, message = "위치는 1자 이상 50자 이하이어야 합니다.")
String location,

@Positive(message = "행 수는 양수여야 합니다.")
@NotNull(message = "행 수는 비어 있을 수 없습니다.")
Integer row,

@Positive(message = "열 수는 양수여야 합니다.")
@NotNull(message = "열 수는 비어 있을 수 없습니다.")
Integer col
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public CreateScheduleRes createSchedule(Long userId, CreateScheduleReq createSch
if(!concert.getUserId().equals(userId)) {
throw new GlobalException(ErrorCase.NOT_PERMITTED_TO_ADD_SCHEDULE);
}

// 공연 시작 날짜 및 종료 날짜 검증
if (createScheduleReq.concertDate().isBefore(concert.getStartDate())) {
throw new GlobalException(ErrorCase.SCHEDULE_START_DATE_TOO_EARLY); // 시작 날짜가 너무 이르다는 오류
}

if (createScheduleReq.concertDate().isAfter(concert.getEndDate())) {
throw new GlobalException(ErrorCase.SCHEDULE_START_DATE_TOO_LATE); // 시작 날짜가 너무 늦다는 오류
}

Schedule schedule = createScheduleReq.toEntity(concert,stage);
return scheduleMapper.toCreateScheduleRes(scheduleRepository.save(schedule));
}
Expand Down Expand Up @@ -77,6 +87,21 @@ public GetScheduleDetailRes getScheduleDetail(Long scheduleId) {
@Transactional
public void updateScheduleById(Long scheduleId, UpdateScheduleReq updateScheduleReq) {
Schedule schedule = getSchedule(scheduleId);

Concert concert = concertRepository.findById(schedule.getConcert().getId())
.orElseThrow(() -> new GlobalException(ErrorCase.NOT_EXIST_CONCERT));

if (updateScheduleReq.concertDate() != null) {
if (updateScheduleReq.concertDate().isBefore(concert.getStartDate())) {
throw new GlobalException(ErrorCase.SCHEDULE_START_DATE_TOO_EARLY);
}

if (updateScheduleReq.concertDate().isAfter(concert.getEndDate())) {
throw new GlobalException(ErrorCase.SCHEDULE_START_DATE_TOO_LATE);
}
schedule.changeConcertDate(updateScheduleReq.concertDate());
}

changeSchedule(updateScheduleReq, schedule);
}

Expand Down
3 changes: 3 additions & 0 deletions application/gateway-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ dependencies {

//kafka
implementation 'org.springframework.kafka:spring-kafka'

// websocket
// implementation 'org.springframework.boot:spring-boot-starter-websocket'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//package com.fortickets.gatewayservice.websocket;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//import org.springframework.web.reactive.socket.WebSocketHandler;
//import org.springframework.web.reactive.socket.WebSocketSession;
//import reactor.core.publisher.Mono;
//
//@Slf4j
//@Component("customWebSocketHandler") // 빈 이름 명시
//public class CustomWebSocketHandler implements WebSocketHandler {
//
// @Override
// public Mono<Void> handle(WebSocketSession session) {
// log.info("New WebSocket connection established: {}", session.getId());
//
// // Echo 메시지 응답 처리
// return session.send(
// session.receive()
// .doOnNext(message -> log.info("Received: {}", message.getPayloadAsText()))
// .map(msg -> session.textMessage("Echo: " + msg.getPayloadAsText()))
// );
// }
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//package com.fortickets.gatewayservice.websocket;
//
//import java.util.HashMap;
//import java.util.Map;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.reactive.HandlerMapping;
//import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
//import org.springframework.web.reactive.socket.WebSocketHandler;
//import org.springframework.web.reactive.socket.server.WebSocketService;
//import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;
//import org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy;
//import org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService;
//import org.springframework.web.reactive.config.EnableWebFlux;
//import org.springframework.web.reactive.config.WebFluxConfigurer;
//
//@Configuration
//@EnableWebFlux
//public class WebSocketConfig implements WebFluxConfigurer {
//
// @Bean
// public WebSocketHandlerAdapter webSocketHandlerAdapter() {
// return new WebSocketHandlerAdapter(customWebSocketService());
// }
//
// @Bean
// public WebSocketService customWebSocketService() {
// return new HandshakeWebSocketService(new ReactorNettyRequestUpgradeStrategy());
// }
//
// @Bean
// public HandlerMapping webSocketMapping(@Qualifier("customWebSocketHandler") WebSocketHandler webSocketHandler) {
// Map<String, WebSocketHandler> map = new HashMap<>();
// map.put("/ws/messages", webSocketHandler);
// return new SimpleUrlHandlerMapping(map, 1);
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public enum ErrorCase {
NOT_EXIST_STAGE(HttpStatus.NOT_FOUND, 3001, "존재하지 않는 공연장입니다."),
NOT_EXIST_CONCERT(HttpStatus.NOT_FOUND, 3002, "존재하지 않는 공연입니다."),
NOT_PERMITTED_TO_ADD_SCHEDULE(HttpStatus.FORBIDDEN, 3003, "해당 공연에 대한 스케줄을 추가할 권한이 없습니다."),
// 400
SCHEDULE_START_DATE_TOO_EARLY(HttpStatus.BAD_REQUEST, 3004, "스케줄은 공연 시작 날짜보다 빠를 수 없습니다."),
// 400
SCHEDULE_START_DATE_TOO_LATE(HttpStatus.BAD_REQUEST, 3005, "스케줄은 공연 종료 날짜보다 늦을 수 없습니다."),


/* Order 4000번대 */
Expand Down