55import org .springframework .stereotype .Service ;
66import org .springframework .transaction .annotation .Transactional ;
77
8+ import com .threestar .trainus .domain .lesson .student .service .StudentLessonService ;
89import com .threestar .trainus .domain .lesson .teacher .entity .Lesson ;
9- import com .threestar .trainus .domain .lesson .teacher .repository .LessonParticipantRepository ;
1010import com .threestar .trainus .domain .lesson .teacher .service .AdminLessonService ;
1111import com .threestar .trainus .domain .metadata .service .ProfileMetadataService ;
1212import com .threestar .trainus .domain .review .dto .ReviewCreateRequestDto ;
1616import com .threestar .trainus .domain .review .mapper .ReviewMapper ;
1717import com .threestar .trainus .domain .review .repository .ReviewRepository ;
1818import com .threestar .trainus .domain .user .entity .User ;
19- import com .threestar .trainus .domain .user .repository .UserRepository ;
2019import com .threestar .trainus .domain .user .service .UserService ;
2120import com .threestar .trainus .global .exception .domain .ErrorCode ;
2221import com .threestar .trainus .global .exception .handler .BusinessException ;
@@ -31,8 +30,7 @@ public class ReviewService {
3130 private final ProfileMetadataService profileMetadataService ;
3231 private final ReviewRepository reviewRepository ;
3332 private final AdminLessonService adminLessonService ;
34- private final UserRepository userRepository ;
35- private final LessonParticipantRepository lessonParticipantRepository ;
33+ private final StudentLessonService studentLessonService ;
3634 private final UserService userService ;
3735
3836 //참여자 테이블에 있는지도 검증 필요 횟수도 한번으로 제한
@@ -51,10 +49,8 @@ public ReviewCreateResponseDto createReview(ReviewCreateRequestDto reviewRequest
5149 User lessonLeader = userService .getUserById (findLesson .getLessonLeader ());
5250
5351 //참여자 테이블 검증 추후 추가 -> lessonId 와 userId 다 갖고 있는지
54- if (!lessonParticipantRepository .existsByLessonIdAndUserId (findLesson .getId (),
55- findUser .getId ())) {
56- throw new BusinessException (ErrorCode .INVALID_LESSON_PARTICIPANT );
57- }
52+ studentLessonService .checkValidLessonParticipant (findLesson , findUser );
53+
5854 if (reviewRepository .existsByReviewer_IdAndLessonId (findUser .getId (), findLesson .getId ())) {
5955 throw new BusinessException (ErrorCode .INVALID_REVIEW_COUNT );
6056 }
0 commit comments