diff --git a/Location-based-target-authentication/src/main/java/com/swyp/global/config/WebConfig.java b/Location-based-target-authentication/src/main/java/com/swyp/global/config/WebConfig.java index 632af73..72fad62 100644 --- a/Location-based-target-authentication/src/main/java/com/swyp/global/config/WebConfig.java +++ b/Location-based-target-authentication/src/main/java/com/swyp/global/config/WebConfig.java @@ -18,6 +18,8 @@ public ViewResolver viewResolver() { return resolver; } + + @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/swagger-ui/**") diff --git a/Location-based-target-authentication/src/main/java/com/swyp/goal/controller/GoalRestController.java b/Location-based-target-authentication/src/main/java/com/swyp/goal/controller/GoalRestController.java index 737d84c..78a5edc 100644 --- a/Location-based-target-authentication/src/main/java/com/swyp/goal/controller/GoalRestController.java +++ b/Location-based-target-authentication/src/main/java/com/swyp/goal/controller/GoalRestController.java @@ -242,16 +242,33 @@ public ResponseEntity getGoalList(@RequestParam("userId") Long userId) { List goalList = goalService.getGoalList(userId); List goalAllDto = new ArrayList<>(); for(Goal goal : goalList) { - List calender = goalService.DateRangeCalculator(goal.getId()); + List calender = goalService.DateRangeCalculator(goal.getId()); // 목표 달력을 위한 전체 날짜값(today가 startDate의 주에 속하면 이번 주 + 다음 주 , today가 startDate의 주에 속하지 않으면 지난주 + 이번 주) System.out.println(calender); - List goalDateDto = new ArrayList<>(); - List logs = goalAchievementLogRepository.findByGoal_IdAndAchievedSuccessIsTrue(goal.getId()); + List goalDateDto = new ArrayList<>(); // 목표 달력을 위한 인증 날짜값 + + // 목표의 시작일부터 종료일까지의 모든 날짜를 생성 + LocalDate startDate = goal.getStartDate(); + LocalDate endDate = goal.getEndDate(); + List allDates = new ArrayList<>(); + LocalDate currentDate = startDate; + while (!currentDate.isAfter(endDate)) { + allDates.add(currentDate); + currentDate = currentDate.plusDays(1); + } + // 인증 성공한 날짜들을 Set으로 변환 (속도 떄문에) + Set successDates = new HashSet<>(); + List achievementLogs = goalAchievementLogRepository + .findByGoal_IdAndAchievedSuccessIsTrue(goal.getId()); + for (GoalAchievementsLog log : achievementLogs) { + successDates.add(log.getAchievedAt()); + } - for (GoalAchievementsLog log : logs) { - GoalDateDto dto = new GoalDateDto(log.getAchievedAt(), log.isAchievedSuccess()); - goalDateDto.add(dto); - } + // 모든 날짜에 대해 인증 상태를 확인하여 DTO 생성 , 인증 성공한 날짜 확인 후 인증 날짜 값 추가 + for (LocalDate date : allDates) { + GoalDateDto dto = new GoalDateDto(date, successDates.contains(date)); + goalDateDto.add(dto); + } // goalDays : 요일 String값으로 가공 List goalDays = goalDayRepository.findByGoalId(goal.getId()); @@ -266,8 +283,8 @@ public ResponseEntity getGoalList(@RequestParam("userId") Long userId) { GoalAllSearchDto dto = new GoalAllSearchDto(goal.getId(),goal.getId(),goal.getName(),goal.getStatus(),goal.getStartDate(),goal.getEndDate(),goal.getLocationName(),goal.getLatitude(),goal.getLongitude(),goal.getRadius(),goal.getTargetCount(),goal.getAchievedCount(), goalDateDto, // 인증된 날짜들 - calender - ,days.toString()); // 날짜 값들 + calender // 날짜 값들 + ,days.toString()); goalAllDto.add(dto); diff --git a/Location-based-target-authentication/src/main/resources/application.properties b/Location-based-target-authentication/src/main/resources/application.properties index fdb3e0e..b4f1c2c 100644 --- a/Location-based-target-authentication/src/main/resources/application.properties +++ b/Location-based-target-authentication/src/main/resources/application.properties @@ -9,8 +9,6 @@ spring.config.import=classpath:application-secret.properties logging.level.com.swyp.location=INFO logging.level.org.springframework.web.reactive.function.client=INFO -spring.mvc.view.prefix=/WEB-INF/views/ -spring.mvc.view.suffix=.jsp # Server Configuration server.port=443