Skip to content

Commit

Permalink
Merge pull request #38 from LetsCareer-A/fix/#37
Browse files Browse the repository at this point in the history
[fix] 해당 유저의 스케쥴인지, 해당 스케쥴의 단계인지 확인하는 로직 추가
  • Loading branch information
pkl0912 authored Sep 1, 2024
2 parents 7ea5ab6 + 5207f98 commit 9b6bfb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class IntReviewService {

@Transactional
public void postIntReview(Long userId, Long scheduleId, Long stageId, PostIntReviewRequest request) {
Schedule schedule = scheduleRepository.findById(scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));
Stage stage = stageRepository.findById(stageId)
.orElseThrow(() -> new NotFoundException(STAGE_NOT_FOUND_EXCEPTION));
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
Schedule schedule = scheduleRepository.findByUserAndScheduleId(user, scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));
Stage stage = stageRepository.findByStageIdAndSchedule(stageId, schedule)
.orElseThrow(() -> new NotFoundException(STAGE_NOT_FOUND_EXCEPTION));

IntReview intReview = IntReview.builder()
.stage(stage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public class MidReviewService {

@Transactional
public void postMidReview(Long userId, Long scheduleId, Long stageId, PostMidReviewRequest request) {
Schedule schedule = scheduleRepository.findById(scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));
Stage stage = stageRepository.findById(stageId)
.orElseThrow(() -> new NotFoundException(STAGE_NOT_FOUND_EXCEPTION));
User user = userRepository.findById(userId)
.orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
Schedule schedule = scheduleRepository.findByUserAndScheduleId(user, scheduleId)
.orElseThrow(() -> new NotFoundException(SCHEDULE_NOT_FOUND_EXCEPTION));
Stage stage = stageRepository.findByStageIdAndSchedule(stageId, schedule)
.orElseThrow(() -> new NotFoundException(STAGE_NOT_FOUND_EXCEPTION));

MidReview midReview = MidReview.builder()
.freeReview(request.free_review())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.example.letscareer.schedule.repository;

import com.example.letscareer.schedule.domain.Schedule;
import com.example.letscareer.user.domain.User;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
Page<Schedule> findAllByUserUserIdAndAlwaysTrue(Long userId, Pageable pageable);

Optional<Schedule> findByUserAndScheduleId(User user, Long scheduleId);
}

0 comments on commit 9b6bfb7

Please sign in to comment.