Skip to content

Commit

Permalink
refactor : 불필요한 주석 해제 및 함수 정리 #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayon-Hong committed May 12, 2024
1 parent 7d30fde commit 4786323
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public class ScheduleController {

private final ScheduleServiceImpl scheduleServiceImpl;

/** 여행 일정 목록 조회 API **/
@GetMapping()
public ResponseEntity<List<ScheduleListResponse>> getScheduleList(@AuthenticationPrincipal CustomUserDetails userDetails) {
String uid = userDetails.getUsername();
List<ScheduleListResponse> scheduleList = scheduleServiceImpl.getScheduleList(uid);
return ResponseEntity.ok(scheduleList);
}

/** 여행 일정 저장 API **/
@PostMapping()
public ResponseEntity<Void> saveSchedule(@AuthenticationPrincipal CustomUserDetails customUserDetails,
Expand All @@ -34,24 +26,25 @@ public ResponseEntity<Void> saveSchedule(@AuthenticationPrincipal CustomUserDeta
return ResponseEntity.ok().build();
}


/** 여행 일정 목록 조회 API **/
@GetMapping()
public ResponseEntity<List<ScheduleListResponse>> getScheduleList(@AuthenticationPrincipal CustomUserDetails userDetails) {
String memberUid = userDetails.getUsername();
List<ScheduleListResponse> scheduleList = scheduleServiceImpl.getScheduleList(memberUid);
return ResponseEntity.ok(scheduleList);
}


/** 여행 일정 상세 조회 API **/
@GetMapping("/details/{scheduleId}")
public ResponseEntity<ScheduleSaveRequest> getScheduleDetail(@AuthenticationPrincipal CustomUserDetails userDetails,
@PathVariable Long scheduleId) {
String uid = userDetails.getUsername();
ScheduleSaveRequest scheduleDetail = scheduleServiceImpl.getScheduleDetail(uid, scheduleId);
String memberUid = userDetails.getUsername();
ScheduleSaveRequest scheduleDetail = scheduleServiceImpl.getScheduleDetail(memberUid, scheduleId);
return ResponseEntity.ok(scheduleDetail);
}

/** 여행 일정 삭제 API **/
@DeleteMapping("/{scheduleId}")
public ResponseEntity<Void> deleteSchedule(@AuthenticationPrincipal CustomUserDetails userDetails,
@PathVariable Long scheduleId) {
String uid = userDetails.getUsername();
scheduleServiceImpl.deleteSchedule(uid, scheduleId);
return ResponseEntity.ok().build();
}


/** 여행 일정 수정 API **/
@PutMapping("/{scheduleId}")
Expand All @@ -62,4 +55,15 @@ public ResponseEntity<ScheduleSaveRequest> updateSchedule(@AuthenticationPrincip
return ResponseEntity.ok(updatedSchedule);
}


/** 여행 일정 삭제 API **/
@DeleteMapping("/{scheduleId}")
public ResponseEntity<Void> deleteSchedule(@AuthenticationPrincipal CustomUserDetails userDetails,
@PathVariable Long scheduleId) {
String memberUid = userDetails.getUsername();
scheduleServiceImpl.deleteSchedule(memberUid, scheduleId);
return ResponseEntity.ok().build();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public class Schedule extends BaseEntity {
@OneToMany(mappedBy = "schedule", cascade = CascadeType.ALL)
private List<ScheduleDetail> scheduleDetails = new ArrayList<>();

// FK 연결 필요
private String bookingId;

private String startDate;

private String endDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
@Query("SELECT s FROM Schedule s WHERE s.member = :member AND s.activated = true ORDER BY s.updatedAt DESC")
List<Schedule> findSchedulesByMember(@Param("member") Member member);


}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ScheduleServiceImpl implements ScheduleService {
private final ScheduleMapper scheduleMapper;


/** 여행 일정 저장 API **/
/** 여행 일정 저장 **/
@Transactional
@Override
public void saveSchedule(String uid, ScheduleSaveRequest scheduleSaveRequest) {
Expand All @@ -52,7 +52,7 @@ public void saveSchedule(String uid, ScheduleSaveRequest scheduleSaveRequest) {
}


/** 여행 일정 목록 조회 API **/
/** 여행 일정 목록 조회 **/
@Override
public List<ScheduleListResponse> getScheduleList(String uid) {
Member findMember = validateUserCheck(uid);
Expand All @@ -65,7 +65,7 @@ public List<ScheduleListResponse> getScheduleList(String uid) {
}


/** 여행 일정 상세 조회 API **/
/** 여행 일정 상세 조회 **/
@Override
public ScheduleSaveRequest getScheduleDetail(String uid, Long scheduleId) {
Member findMember = validateUserCheck(uid);
Expand All @@ -75,27 +75,7 @@ public ScheduleSaveRequest getScheduleDetail(String uid, Long scheduleId) {
}


/** 여행 일정 삭제 API **/
@Transactional
@Override
public void deleteSchedule(String uid, Long scheduleId) {
Member findMember = validateUserCheck(uid);
Schedule findSchedule = validateSchedule(scheduleId);

// 자신의 여행 일정인지 확인
if (!findSchedule.getMember().equals(findMember)) {
throw new NotYourScheduleException();
}

// ScheduleDetail 테이블 데이터 삭제
scheduleDetailRepository.deleteBySchedule(findSchedule);
findSchedule.setActivated(false);

scheduleRepository.save(findSchedule);
}


/** 여행 일정 수정 API **/
/** 여행 일정 수정 **/
@Transactional
@Override
public ScheduleSaveRequest updateSchedule(String uid, Long scheduleId, ScheduleSaveRequest updateRequestDTO) {
Expand Down Expand Up @@ -129,6 +109,25 @@ public ScheduleSaveRequest updateSchedule(String uid, Long scheduleId, ScheduleS
}


/** 여행 일정 삭제 **/
@Transactional
@Override
public void deleteSchedule(String uid, Long scheduleId) {
Member findMember = validateUserCheck(uid);
Schedule findSchedule = validateSchedule(scheduleId);
// 자신의 여행 일정인지 확인
if (!findSchedule.getMember().equals(findMember)) {
throw new NotYourScheduleException();
}

// ScheduleDetail 테이블 데이터 삭제
scheduleDetailRepository.deleteBySchedule(findSchedule);
findSchedule.setActivated(false);

scheduleRepository.save(findSchedule);
}


/** 여행 일정 총 경비 계산 **/
@Override
public void calculateTotalPrice(Schedule schedule) {
Expand Down

0 comments on commit 4786323

Please sign in to comment.