diff --git a/src/main/java/com/haemil/backend/schedule/controller/ScheduleController.java b/src/main/java/com/haemil/backend/schedule/controller/ScheduleController.java index a2c35d9..baf0d55 100644 --- a/src/main/java/com/haemil/backend/schedule/controller/ScheduleController.java +++ b/src/main/java/com/haemil/backend/schedule/controller/ScheduleController.java @@ -37,10 +37,7 @@ public ResponseEntity createSchedule(@RequestBody ScheduleRequestD try { ScheduleResponseDto createSchedule = scheduleService.createSchedule(scheduleRequestDto); - - // 맵 API 호출하여 맵 URL 얻어오는 부분 String mapUrl = mapService.getMapUrl(scheduleRequestDto.getPlace()); - // 응답에 맵 URL을 포함하여 리턴 createSchedule.setMapUrl(mapUrl); BaseResponse response = new BaseResponse<>(createSchedule); @@ -98,12 +95,9 @@ public ResponseEntity deleteSchedule(@PathVariable Long scheduleId public ResponseEntity updateSchedule(@PathVariable Long scheduleId, @RequestBody ScheduleRequestDto requestDto) { try { Schedule updateSchedule = scheduleService.updateSchedule(scheduleId, requestDto); - log.debug("requestDto.getPlace() = {}",requestDto.getPlace()); - // 맵 API 호출하여 맵 URL 얻어오는 부분 String mapUrl = mapService.getMapUrl(requestDto.getPlace()); - // 응답에 맵 URL을 포함하여 리턴 updateSchedule.setMapUrl(mapUrl); System.out.println(mapUrl); diff --git a/src/main/java/com/haemil/backend/schedule/dto/ScheduleRequestDto.java b/src/main/java/com/haemil/backend/schedule/dto/ScheduleRequestDto.java index 92d239b..e1ec60f 100644 --- a/src/main/java/com/haemil/backend/schedule/dto/ScheduleRequestDto.java +++ b/src/main/java/com/haemil/backend/schedule/dto/ScheduleRequestDto.java @@ -17,8 +17,6 @@ public class ScheduleRequestDto { private LocalDate localDate; - private DayOfWeek dayOfWeek; - private LocalTime time; private String content; @@ -27,8 +25,6 @@ public class ScheduleRequestDto { private String place; - private String medicine; - private RepeatType repeatType; diff --git a/src/main/java/com/haemil/backend/schedule/dto/ScheduleResponseDto.java b/src/main/java/com/haemil/backend/schedule/dto/ScheduleResponseDto.java index 5aabe09..1dede8c 100644 --- a/src/main/java/com/haemil/backend/schedule/dto/ScheduleResponseDto.java +++ b/src/main/java/com/haemil/backend/schedule/dto/ScheduleResponseDto.java @@ -23,8 +23,6 @@ public class ScheduleResponseDto { private LocalDate localDate; - private DayOfWeek dayOfWeek; - private LocalTime time; private String content; @@ -33,8 +31,6 @@ public class ScheduleResponseDto { private Boolean done; - private String medicine; - private RepeatType repeatType; @@ -45,8 +41,6 @@ public ScheduleResponseDto(Schedule schedule){ this.localDate = schedule.getLocalDate(); - this.dayOfWeek = schedule.getDayOfWeek(); - this.time = schedule.getTime(); this.content = schedule.getContent(); @@ -55,8 +49,6 @@ public ScheduleResponseDto(Schedule schedule){ this.done = schedule.getDone(); - this.medicine = schedule.getMedicine(); - this.repeatType = schedule.getRepeatType(); } diff --git a/src/main/java/com/haemil/backend/schedule/entity/Schedule.java b/src/main/java/com/haemil/backend/schedule/entity/Schedule.java index d691f2c..4f3734b 100644 --- a/src/main/java/com/haemil/backend/schedule/entity/Schedule.java +++ b/src/main/java/com/haemil/backend/schedule/entity/Schedule.java @@ -24,10 +24,6 @@ public class Schedule { @Column(nullable = false) private LocalDate localDate; - //요일 - @Column(nullable = false) - private DayOfWeek dayOfWeek; - //일정 시간(hour, minute, second, nano) @Column(nullable = false) private LocalTime time; @@ -44,10 +40,6 @@ public class Schedule { @Column(nullable = true, length = 50) private String place; - //약 - @Column(nullable = true, length = 50) - private String medicine; - //반복 routine @Enumerated(value = EnumType.STRING) @Column(nullable = false) diff --git a/src/main/java/com/haemil/backend/schedule/repository/ScheduleRepository.java b/src/main/java/com/haemil/backend/schedule/repository/ScheduleRepository.java index d3cf5cf..3b0b5ea 100644 --- a/src/main/java/com/haemil/backend/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/haemil/backend/schedule/repository/ScheduleRepository.java @@ -15,7 +15,6 @@ import java.util.Optional; @Primary -//JpaRepository를 상속받아서 데이터베이스와 상호작용하는 메서드들 제공 public interface ScheduleRepository extends JpaRepository { //일정을 조회 diff --git a/src/main/java/com/haemil/backend/schedule/service/ScheduleService.java b/src/main/java/com/haemil/backend/schedule/service/ScheduleService.java index 6efcfa8..650f7a2 100644 --- a/src/main/java/com/haemil/backend/schedule/service/ScheduleService.java +++ b/src/main/java/com/haemil/backend/schedule/service/ScheduleService.java @@ -25,9 +25,6 @@ import java.util.Optional; - -//Schedule 객체를 저장하고 조회하는 기능을 구현 -//ScheduleRepository를 사용하여 데이터베이스와 상호작용 @Slf4j @Transactional public class ScheduleService { @@ -41,40 +38,34 @@ public ScheduleService(ScheduleRepository scheduleRepository) { public ScheduleResponseDto createSchedule(ScheduleRequestDto scheduleRequestDto) throws BaseException { try { LocalDate localDate = scheduleRequestDto.getLocalDate(); - DayOfWeek dayOfWeek = scheduleRequestDto.getDayOfWeek(); String content = scheduleRequestDto.getContent(); Boolean done = scheduleRequestDto.getDone(); LocalTime time = scheduleRequestDto.getTime(); String place = scheduleRequestDto.getPlace(); - String medicine = scheduleRequestDto.getMedicine(); RepeatType repeatType = scheduleRequestDto.getRepeatType(); Schedule schedule = new Schedule(); schedule.setLocalDate(localDate); - schedule.setDayOfWeek(dayOfWeek); schedule.setContent(content); schedule.setDone(done); schedule.setTime(time); schedule.setPlace(place); schedule.setRepeatType(repeatType); - schedule.setMedicine(medicine); // missing field 존재 여부 검사 - if (localDate == null || dayOfWeek == null || time == null || content == null || done == null || repeatType == null) { + if (localDate == null || time == null || content == null || done == null || repeatType == null) { throw new MissingRequiredFieldException("Required field(s) are missing"); } // 여기서 중복 일정 검사를 수행하고 이미 존재하는 경우 예외를 던짐 List existingSchedules = scheduleRepository.findByLocalDate(localDate); for (Schedule existingSchedule : existingSchedules) { - if (existingSchedule.getDayOfWeek() == dayOfWeek && - existingSchedule.getTime().equals(time) && + if (existingSchedule.getTime().equals(time) && existingSchedule.getContent().equals(content) && existingSchedule.getDone().equals(done) && existingSchedule.getRepeatType().equals(repeatType) && - existingSchedule.getPlace().equals(place) && - existingSchedule.getMedicine().equals(medicine)) { + existingSchedule.getPlace().equals(place)) { throw new BaseException(ResponseStatus.CONFLICT); } } @@ -99,7 +90,7 @@ public List getSchedule(LocalDate localDate) throws BaseException { } return schedules; } catch (BaseException e) { - throw new BaseException(ResponseStatus.NOT_FOUND); // 현재의 예외를 다시 던져줍니다. + throw new BaseException(ResponseStatus.NOT_FOUND); } } @@ -114,12 +105,10 @@ public List getTodaySchedules() throws BaseException { if (todaySchedules.isEmpty()) { throw new BaseException(ResponseStatus.NOT_FOUND); } - return todaySchedules; - } catch (BaseException e) { - throw new BaseException(ResponseStatus.NOT_FOUND); // 현재의 예외를 다시 던져줍니다. + throw new BaseException(ResponseStatus.NOT_FOUND); } } @@ -148,42 +137,35 @@ public Schedule updateSchedule(Long id, ScheduleRequestDto requestDto) { Schedule schedule = scheduleRepository.findById(id).orElse(null); LocalDate newLocalDate = requestDto.getLocalDate(); - DayOfWeek newDayOfWeek = requestDto.getDayOfWeek(); String newContent = requestDto.getContent(); Boolean newDone = requestDto.getDone(); LocalTime newTime = requestDto.getTime(); String newPlace = requestDto.getPlace(); - String newMedicine = requestDto.getMedicine(); RepeatType newRepeatType = requestDto.getRepeatType(); - if (newLocalDate == null || newDayOfWeek == null || newTime == null || newContent == null || newDone == null || newRepeatType == null) { + if (newLocalDate == null || newTime == null || newContent == null || newDone == null || newRepeatType == null) { throw new MissingRequiredFieldException("Required field(s) are missing in updated schedule"); } + // 여기서 중복 일정 검사를 수행하고 이미 존재하는 경우 예외를 던짐 List existingSchedules = scheduleRepository.findByLocalDate(newLocalDate); for (Schedule existingSchedule : existingSchedules) { - System.out.println("existingSchedule: " + existingSchedule); if ( - existingSchedule.getDayOfWeek() == newDayOfWeek && - existingSchedule.getTime().equals(newTime) && + existingSchedule.getTime().equals(newTime) && existingSchedule.getContent().equals(newContent) && existingSchedule.getDone().equals(newDone) && existingSchedule.getRepeatType().equals(newRepeatType) && - existingSchedule.getPlace().equals(newPlace) && - existingSchedule.getMedicine().equals(newMedicine)) { + existingSchedule.getPlace().equals(newPlace) + ) { throw new BaseException(ResponseStatus.CONFLICT); } } schedule.setLocalDate(newLocalDate); - schedule.setDayOfWeek(newDayOfWeek); schedule.setContent(newContent); schedule.setDone(newDone); schedule.setTime(newTime); schedule.setPlace(newPlace); schedule.setRepeatType(newRepeatType); - schedule.setMedicine(newMedicine); - - log.debug("newContent = {}", newContent); return scheduleRepository.save(schedule); diff --git a/src/test/java/com/haemil/backend/schedule/service/ScheduleServiceTest.java b/src/test/java/com/haemil/backend/schedule/service/ScheduleServiceTest.java index d3f37e1..9a48828 100644 --- a/src/test/java/com/haemil/backend/schedule/service/ScheduleServiceTest.java +++ b/src/test/java/com/haemil/backend/schedule/service/ScheduleServiceTest.java @@ -42,7 +42,7 @@ void createSchedule(){ LocalTime time = LocalTime.of(5, 3); String place = "Test Place"; - //when + /*//when Schedule schedule = scheduleService.createSchedule(creationDate, dayOfWeek, content, important_schedule, fixed_schedule, time, place); //then @@ -52,7 +52,7 @@ void createSchedule(){ assertThat(schedule.isImportant()).isEqualTo(important_schedule); assertThat(schedule.isFixed()).isEqualTo(fixed_schedule); assertThat(schedule.getTime()).isEqualTo(time); - assertThat(schedule.getPlace()).isEqualTo(place); + assertThat(schedule.getPlace()).isEqualTo(place);*/ }