Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public ViewResolver viewResolver() {
return resolver;
}



@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/swagger-ui/**")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,33 @@ public ResponseEntity<?> getGoalList(@RequestParam("userId") Long userId) {
List<Goal> goalList = goalService.getGoalList(userId);
List<GoalAllSearchDto> goalAllDto = new ArrayList<>();
for(Goal goal : goalList) {
List<LocalDate> calender = goalService.DateRangeCalculator(goal.getId());
List<LocalDate> calender = goalService.DateRangeCalculator(goal.getId()); // 목표 달력을 위한 전체 날짜값(today가 startDate의 주에 속하면 이번 주 + 다음 주 , today가 startDate의 주에 속하지 않으면 지난주 + 이번 주)
System.out.println(calender);
List<GoalDateDto> goalDateDto = new ArrayList<>();
List<GoalAchievementsLog> logs = goalAchievementLogRepository.findByGoal_IdAndAchievedSuccessIsTrue(goal.getId());
List<GoalDateDto> goalDateDto = new ArrayList<>(); // 목표 달력을 위한 인증 날짜값

// 목표의 시작일부터 종료일까지의 모든 날짜를 생성
LocalDate startDate = goal.getStartDate();
LocalDate endDate = goal.getEndDate();
List<LocalDate> allDates = new ArrayList<>();
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
allDates.add(currentDate);
currentDate = currentDate.plusDays(1);
}

// 인증 성공한 날짜들을 Set으로 변환 (속도 떄문에)
Set<LocalDate> successDates = new HashSet<>();
List<GoalAchievementsLog> 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<GoalDay> goalDays = goalDayRepository.findByGoalId(goal.getId());
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down