diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java index ea58a499..96af0b6a 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java @@ -4,8 +4,10 @@ import static org.sopt.makers.crew.main.global.exception.ErrorStatus.*; import static org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus.*; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.time.LocalDateTime; @@ -150,7 +152,6 @@ public List getMeetingBanner() { return getResponseDto(meetings, postMap, applies); } - private List filterLatestPostsByMeetingId(List posts) { return posts.stream() .collect(Collectors.groupingBy(Post::getMeetingId, @@ -384,9 +385,15 @@ private void deleteCsvFile(String filePath) { private String createCsvFile(List applies) { String filePath = UUID.randomUUID() + ".csv"; - try (CSVWriter writer = new CSVWriter(new FileWriter(filePath))) { + try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter( + new FileOutputStream(filePath), StandardCharsets.UTF_8); + CSVWriter writer = new CSVWriter(outputStreamWriter)) { + + // BOM 추가 (Excel에서 UTF-8 파일을 제대로 처리하기 위함) + outputStreamWriter.write("\uFEFF"); + // CSV 파일의 헤더 정의 - String[] header = {"이름", "최근 활동 파트", "최근 활동 기수", "전화번호", "신청 날짜 및 시간", "신청 내용", "신청 상태"}; + String[] header = {"이름", "최근 활동 파트", "최근 활동 기수", "전화번호", "신청 날짜 및 시간", "신청 상태"}; writer.writeNext(header); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @@ -400,7 +407,6 @@ private String createCsvFile(List applies) { String.valueOf(activity.getGeneration()), String.format("\"%s\"", user.getPhone()), apply.getAppliedDate().format(formatter), - apply.getContent(), apply.getStatus().getDescription() }; writer.writeNext(data);