33import com .back .domain .study .plan .dto .StudyPlanDeleteRequest ;
44import com .back .domain .study .plan .dto .StudyPlanRequest ;
55import com .back .domain .study .plan .dto .StudyPlanResponse ;
6- import com .back .domain .study .plan .entity .RepeatRule ;
7- import com .back .domain .study .plan .entity .RepeatRuleEmbeddable ;
8- import com .back .domain .study .plan .entity .StudyPlan ;
9- import com .back .domain .study .plan .entity .StudyPlanException ;
6+ import com .back .domain .study .plan .entity .*;
107import com .back .domain .study .plan .repository .StudyPlanExceptionRepository ;
118import com .back .domain .study .plan .repository .StudyPlanRepository ;
129import com .back .global .exception .CustomException ;
@@ -211,7 +208,7 @@ private StudyPlanException getEffectiveException(Long planId, LocalDate targetDa
211208 List <StudyPlanException > scopeExceptions = studyPlanExceptionRepository
212209 .findByStudyPlanIdAndApplyScopeAndExceptionDateBefore (
213210 planId ,
214- StudyPlanException . ApplyScope .FROM_THIS_DATE ,
211+ ApplyScope .FROM_THIS_DATE ,
215212 targetDate .atStartOfDay ()
216213 );
217214
@@ -280,7 +277,7 @@ private enum UpdateType {
280277 REPEAT_INSTANCE_UPDATE // 기존 예외 수정
281278 }
282279 @ Transactional
283- public StudyPlanResponse updateStudyPlan (Long userId , Long planId , StudyPlanRequest request , StudyPlanException . ApplyScope applyScope ) {
280+ public StudyPlanResponse updateStudyPlan (Long userId , Long planId , StudyPlanRequest request , ApplyScope applyScope ) {
284281 StudyPlan originalPlan = studyPlanRepository .findById (planId )
285282 .orElseThrow (() -> new CustomException (ErrorCode .PLAN_NOT_FOUND ));
286283
@@ -348,7 +345,7 @@ private StudyPlanResponse updateOriginalPlan(StudyPlan originalPlan, StudyPlanRe
348345 }
349346
350347 // 새로운 예외 추가
351- private StudyPlanResponse createRepeatException (StudyPlan originalPlan , StudyPlanRequest request , StudyPlanException . ApplyScope applyScope ) {
348+ private StudyPlanResponse createRepeatException (StudyPlan originalPlan , StudyPlanRequest request , ApplyScope applyScope ) {
352349 LocalDate exceptionDate = request .getStartDate ().toLocalDate ();
353350
354351 // 해당 날짜에 실제로 반복 계획이 있는지 확인
@@ -393,7 +390,7 @@ private StudyPlanResponse createRepeatException(StudyPlan originalPlan, StudyPla
393390 }
394391
395392 // 기존 예외 수정
396- private StudyPlanResponse updateExistingException (StudyPlan originalPlan , StudyPlanRequest request , StudyPlanException . ApplyScope applyScope ) {
393+ private StudyPlanResponse updateExistingException (StudyPlan originalPlan , StudyPlanRequest request , ApplyScope applyScope ) {
397394 LocalDate exceptionDate = request .getStartDate ().toLocalDate ();
398395
399396 StudyPlanException existingException = studyPlanExceptionRepository
@@ -451,24 +448,24 @@ private void updateRepeatRule(RepeatRule repeatRule, StudyPlanRequest.RepeatRule
451448
452449 // ==================== 삭제 ===================
453450 @ Transactional
454- public void deleteStudyPlan (Long userId , Long planId , LocalDate selectedDate , StudyPlanDeleteRequest request ) {
451+ public void deleteStudyPlan (Long userId , Long planId , LocalDate selectedDate , ApplyScope applyScope ) {
455452 StudyPlan studyPlan = studyPlanRepository .findById (planId )
456453 .orElseThrow (() -> new CustomException (ErrorCode .PLAN_NOT_FOUND ));
457454
458455 validateUserAccess (studyPlan , userId );
459456
460- // 단발성 계획 삭제 (request가 null이거나 deleteScope가 없는 경우)
461- if (studyPlan .getRepeatRule () == null || request == null || request . getDeleteScope () == null ) {
457+ // 단발성 계획 삭제 (반복 룰이 null이거나 applyScope가 null인 경우)
458+ if (studyPlan .getRepeatRule () == null || applyScope == null ) {
462459 studyPlanRepository .delete (studyPlan );
463460 return ;
464461 }
465462
466- // 반복성 계획 삭제 - deleteScope에 따른 처리
467- deleteRepeatPlan (studyPlan , selectedDate , request . getDeleteScope () );
463+ // 반복성 계획 삭제 - applyScope에 따른 처리
464+ deleteRepeatPlan (studyPlan , selectedDate , applyScope );
468465 }
469466
470- private void deleteRepeatPlan (StudyPlan studyPlan , LocalDate selectedDate , StudyPlanDeleteRequest . DeleteScope deleteScope ) {
471- switch (deleteScope ) {
467+ private void deleteRepeatPlan (StudyPlan studyPlan , LocalDate selectedDate , ApplyScope applyScope ) {
468+ switch (applyScope ) {
472469 case FROM_THIS_DATE :
473470 // 원본 날짜부터 삭제하는 경우 = 전체 계획 삭제
474471 if (selectedDate .equals (studyPlan .getStartDate ().toLocalDate ())) {
@@ -488,7 +485,7 @@ private void deleteRepeatPlan(StudyPlan studyPlan, LocalDate selectedDate, Study
488485 exception .setStudyPlan (studyPlan );
489486 exception .setExceptionDate (selectedDate );
490487 exception .setExceptionType (StudyPlanException .ExceptionType .DELETED );
491- exception .setApplyScope (StudyPlanException . ApplyScope .THIS_ONLY );
488+ exception .setApplyScope (ApplyScope .THIS_ONLY );
492489 studyPlanExceptionRepository .save (exception );
493490 break ;
494491 }
0 commit comments