diff --git a/backend/src/main/java/com/isp/backend/domain/schedule/controller/ScheduleController.java b/backend/src/main/java/com/isp/backend/domain/schedule/controller/ScheduleController.java index 97c1b186..2406357e 100644 --- a/backend/src/main/java/com/isp/backend/domain/schedule/controller/ScheduleController.java +++ b/backend/src/main/java/com/isp/backend/domain/schedule/controller/ScheduleController.java @@ -2,6 +2,7 @@ import com.isp.backend.domain.schedule.dto.ScheduleListResponseDTO; import com.isp.backend.domain.schedule.dto.ScheduleRequestDTO; +import com.isp.backend.domain.schedule.dto.ScheduleResponseDTO; import com.isp.backend.domain.schedule.dto.ScheduleSaveRequestDTO; import com.isp.backend.domain.schedule.entity.Schedule; import com.isp.backend.domain.schedule.service.ScheduleService; @@ -21,13 +22,12 @@ public class ScheduleController { private final ScheduleService scheduleService; - // @PostMapping("/") - // @ResponseStatus(HttpStatus.OK) - // public ScheduleResponseDTO login(@RequestBody ScheduleRequestDTO scheduleRequestDTO) { - // return new ScheduleResponseDTO(schedule); - // Schedule schedule = scheduleService.create(scheduleRequestDTO.toEntity()); - // } + @PostMapping("/") + public ResponseEntity createSchedule(@RequestBody ScheduleRequestDTO scheduleRequestDTO) { + ScheduleResponseDTO scheduleResponseDTO = scheduleService.createSchedule(scheduleRequestDTO); + return ResponseEntity.ok(scheduleResponseDTO); + } /** * 여행 일정 저장 API */ @@ -49,7 +49,6 @@ public ResponseEntity> getScheduleList(@Authentica return ResponseEntity.ok(scheduleList); } - /** * 여행 일정 상세 조회 API */ @@ -61,7 +60,6 @@ public ResponseEntity getScheduleDetail(@AuthenticationP return ResponseEntity.ok(scheduleDetail); } - /** * 여행 일정 삭제 API */ diff --git a/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleRequestDTO.java b/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleRequestDTO.java index 178513ec..fd526276 100644 --- a/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleRequestDTO.java +++ b/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleRequestDTO.java @@ -1,5 +1,7 @@ package com.isp.backend.domain.schedule.dto; +import com.isp.backend.domain.country.entity.Country; +import com.isp.backend.domain.schedule.entity.Schedule; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,8 +12,16 @@ @NoArgsConstructor @AllArgsConstructor public class ScheduleRequestDTO { - private String destination; + private Country country; private String purpose; - private String departureDate; - private String returnDate; + private String startDate; + private String endDate; + + public Schedule toEntity() { + return Schedule.builder() + .country(country) + .startDate(startDate) + .endDate(endDate) + .build(); + } } diff --git a/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleResponseDTO.java b/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleResponseDTO.java new file mode 100644 index 00000000..6c2425be --- /dev/null +++ b/backend/src/main/java/com/isp/backend/domain/schedule/dto/ScheduleResponseDTO.java @@ -0,0 +1,17 @@ +package com.isp.backend.domain.schedule.dto; + +import com.isp.backend.domain.schedule.entity.Schedule; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class ScheduleResponseDTO { + private String name; + private String email; + + public ScheduleResponseDTO(Schedule schedule) { + } +} diff --git a/backend/src/main/java/com/isp/backend/domain/schedule/service/ScheduleService.java b/backend/src/main/java/com/isp/backend/domain/schedule/service/ScheduleService.java index dc35bdfd..00963cd5 100644 --- a/backend/src/main/java/com/isp/backend/domain/schedule/service/ScheduleService.java +++ b/backend/src/main/java/com/isp/backend/domain/schedule/service/ScheduleService.java @@ -8,15 +8,19 @@ import com.isp.backend.domain.country.repository.CountryRepository; import com.isp.backend.domain.member.entity.Member; import com.isp.backend.domain.member.repository.MemberRepository; -import com.isp.backend.domain.scheduleDetail.entity.ScheduleDetail; -import com.isp.backend.domain.scheduleDetail.repository.ScheduleDetailRepository; +import com.isp.backend.domain.schedule.dto.ScheduleListResponseDTO; +import com.isp.backend.domain.schedule.dto.ScheduleRequestDTO; +import com.isp.backend.domain.schedule.dto.ScheduleResponseDTO; import com.isp.backend.domain.schedule.dto.ScheduleSaveRequestDTO; import com.isp.backend.domain.schedule.entity.Schedule; import com.isp.backend.domain.schedule.mapper.ScheduleMapper; import com.isp.backend.domain.schedule.repository.ScheduleRepository; +import com.isp.backend.domain.scheduleDetail.entity.ScheduleDetail; +import com.isp.backend.domain.scheduleDetail.repository.ScheduleDetailRepository; import com.isp.backend.global.exception.member.MemberNotFoundException; import com.isp.backend.global.exception.schedule.CountryNotFoundException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +38,12 @@ public class ScheduleService { private final MemberRepository memberRepository ; private final ScheduleMapper scheduleMapper; + @Transactional + public ScheduleResponseDTO createSchedule(ScheduleRequestDTO scheduleRequestDTO) { + // 프롬프트 생성하고 + // schedule 일정 생성하기 openai 써서 + return null; + } /** @@ -185,9 +195,4 @@ private void calculateTotalPrice(Schedule schedule) { .sum(); schedule.setTotalPrice(totalPrice); } - - - - - }