Skip to content

Commit 3fbecd4

Browse files
authored
Merge pull request #126 from studio-recoding/dev
[🔧fix] 17차 배포
2 parents 71e1e6e + 046261b commit 3fbecd4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/main/java/Ness/Backend/domain/report/ReportService.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
import org.springframework.stereotype.Service;
2424
import org.springframework.transaction.annotation.Transactional;
2525

26+
import java.time.LocalDate;
2627
import java.time.ZoneId;
2728
import java.time.ZonedDateTime;
2829
import java.util.List;
30+
import java.util.stream.Stream;
2931

3032
@Service
3133
@RequiredArgsConstructor
@@ -71,6 +73,36 @@ public GetReportMemoryListDto getMemory(Long memberId){
7173
return createReportMemoryListDto(reportMemories);
7274
}
7375

76+
public GetReportMemoryListDto createReportMemoryListDto(List<ReportMemory> reportMemories) {
77+
ZoneId koreaZoneId = ZoneId.of("Asia/Seoul");
78+
LocalDate startDate = ZonedDateTime.now(koreaZoneId).toLocalDate().minusDays(13);
79+
80+
// 주어진 기간 내의 모든 날짜 리스트 생성
81+
List<LocalDate> allDates = Stream.iterate(startDate, date -> date.plusDays(1))
82+
.limit(14)
83+
.toList();
84+
85+
List<GetReportMemoryDto> getReportMemoryDtos = allDates.stream()
86+
.map(date -> {
87+
// 해당 날짜의 ReportMemory 객체를 찾음 (한국 시간대 기준으로 LocalDate 비교)
88+
ReportMemory memory = reportMemories.stream()
89+
.filter(m -> m.getCreatedDate().withZoneSameInstant(koreaZoneId).toLocalDate().equals(date))
90+
.findFirst()
91+
.orElse(null);
92+
93+
// ReportMemory 객체가 존재하면 해당 객체를 기반으로 DTO 생성, 없으면 임시 DTO 생성
94+
return GetReportMemoryDto.builder()
95+
.id(memory != null ? memory.getId() : 0) // 존재하지 않으면 ID는 0
96+
.createdDate(memory != null ? memory.getCreatedDate().toString() : date.atStartOfDay(koreaZoneId).toString()) // 존재하지 않으면 해당 날짜의 00:00 KST 사용
97+
.memory(memory != null ? memory.getMemory() : "\uD83C\uDE1A") // 임시 메모리 데이터
98+
.build();
99+
})
100+
.toList();
101+
102+
return new GetReportMemoryListDto(getReportMemoryDtos);
103+
}
104+
105+
/*
74106
public GetReportMemoryListDto createReportMemoryListDto(List<ReportMemory> reportMemories) {
75107
//ReportMemoryListResponseDto에 매핑
76108
List<GetReportMemoryDto> getReportMemoryDtos = reportMemories.stream()
@@ -83,6 +115,7 @@ public GetReportMemoryListDto createReportMemoryListDto(List<ReportMemory> repor
83115
84116
return new GetReportMemoryListDto(getReportMemoryDtos);
85117
}
118+
*/
86119

87120
public String postNewAiMemory(Long memberId, ZonedDateTime today){
88121
String persona = getPersona(memberId);
@@ -229,6 +262,8 @@ public PostFastApiAiRecommendActivityDto postNewAiRecommend(Long memberId, Zoned
229262
}
230263

231264
public String parseAiRecommend(String text){
265+
// AI에서 이 접두사를 붙여서 반환하는 경우가 많이 발생함
266+
text = text.replace("AI Recommendation: ", "");
232267
return text.replace("\"", "");
233268
}
234269

0 commit comments

Comments
 (0)