From 14135485c6a2f10069292797d3d4e8194d218685 Mon Sep 17 00:00:00 2001 From: 88dldl Date: Tue, 9 Jul 2024 22:20:33 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20[Refactor]=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=EC=97=90=EC=84=9C=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84(ms)=EB=A7=8C=20=EC=B6=94=EC=B6=9C=ED=95=B4=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ssuPlector/controller/PmController.java | 10 +++++--- .../ssuPlector/converter/PmConverter.java | 23 +++++++++++++++++++ .../java/ssuPlector/dto/response/PmDTO.java | 23 +++++++++++++++++++ .../java/ssuPlector/service/pm/PmService.java | 4 +++- .../ssuPlector/service/pm/PmServiceImpl.java | 23 ++++++++++++++++--- 5 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 src/main/java/ssuPlector/converter/PmConverter.java create mode 100644 src/main/java/ssuPlector/dto/response/PmDTO.java diff --git a/src/main/java/ssuPlector/controller/PmController.java b/src/main/java/ssuPlector/controller/PmController.java index 34503bf..ba00f0b 100644 --- a/src/main/java/ssuPlector/controller/PmController.java +++ b/src/main/java/ssuPlector/controller/PmController.java @@ -1,5 +1,7 @@ package ssuPlector.controller; +import java.util.List; + import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -7,7 +9,9 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import ssuPlector.converter.PmConverter; import ssuPlector.dto.request.PmDTO.PmRequestDTO; +import ssuPlector.dto.response.PmDTO.PmResponseDTO; import ssuPlector.global.response.ApiResponse; import ssuPlector.service.pm.PmService; @@ -20,12 +24,12 @@ public class PmController { @Operation(summary = "회의 진행", description = "입력 값을 받아 회의 진행을 추천합니다._숙희") @GetMapping("/meeting") - public ApiResponse recommendMeetingProgress( + public ApiResponse recommendMeetingProgress( @ModelAttribute PmRequestDTO pmRequestDTO, @RequestParam(value = "time") long time, @RequestParam(value = "numberOfParticipants") int numberOfParticipants) { - String meeting = pmService.recommendMeeting(pmRequestDTO, time, numberOfParticipants); - return ApiResponse.onSuccess("회의 진행 추천 완료", meeting); + List meeting = pmService.recommendMeeting(pmRequestDTO, time, numberOfParticipants); + return ApiResponse.onSuccess("회의 진행 추천 완료", PmConverter.toPmResponseDTO(meeting)); } @Operation(summary = "음성 회의록 정리", description = "음성 회의록을 정리 요약합니다._찬민") diff --git a/src/main/java/ssuPlector/converter/PmConverter.java b/src/main/java/ssuPlector/converter/PmConverter.java new file mode 100644 index 0000000..f48f3fb --- /dev/null +++ b/src/main/java/ssuPlector/converter/PmConverter.java @@ -0,0 +1,23 @@ +package ssuPlector.converter; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import ssuPlector.dto.response.PmDTO.PmResponseDTO; + +@Component +public class PmConverter { + public static PmResponseDTO toPmResponseDTO(List timelist) { + return PmResponseDTO.builder() + .introduceMyself(timelist.get(0)) + .iceBreaking(timelist.get(1)) + .brainstorming(timelist.get(2)) + .topicSelection(timelist.get(3)) + .progressSharing(timelist.get(4)) + .roleDivision(timelist.get(5)) + .troubleShooting(timelist.get(6)) + .feedback(timelist.get(7)) + .build(); + } +} diff --git a/src/main/java/ssuPlector/dto/response/PmDTO.java b/src/main/java/ssuPlector/dto/response/PmDTO.java new file mode 100644 index 0000000..c660bdd --- /dev/null +++ b/src/main/java/ssuPlector/dto/response/PmDTO.java @@ -0,0 +1,23 @@ +package ssuPlector.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +public class PmDTO { + @Getter + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class PmResponseDTO { + private long introduceMyself; + private long iceBreaking; + private long brainstorming; + private long topicSelection; + private long progressSharing; + private long roleDivision; + private long troubleShooting; + private long feedback; + } +} diff --git a/src/main/java/ssuPlector/service/pm/PmService.java b/src/main/java/ssuPlector/service/pm/PmService.java index 7480c2e..2ef3c72 100644 --- a/src/main/java/ssuPlector/service/pm/PmService.java +++ b/src/main/java/ssuPlector/service/pm/PmService.java @@ -1,11 +1,13 @@ package ssuPlector.service.pm; +import java.util.List; + import org.springframework.web.multipart.MultipartFile; import ssuPlector.dto.request.PmDTO.PmRequestDTO; public interface PmService { - String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberOfParticipants); + List recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberOfParticipants); String summarize(MultipartFile file); } diff --git a/src/main/java/ssuPlector/service/pm/PmServiceImpl.java b/src/main/java/ssuPlector/service/pm/PmServiceImpl.java index 4ddd4f2..33c90d1 100644 --- a/src/main/java/ssuPlector/service/pm/PmServiceImpl.java +++ b/src/main/java/ssuPlector/service/pm/PmServiceImpl.java @@ -26,7 +26,8 @@ public class PmServiceImpl implements PmService { private final ClovaService clovaService; @Override - public String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberOfParticipants) { + public List recommendMeeting( + PmRequestDTO pmRequestDTO, long time, int numberOfParticipants) { long minutes = time / (1000 * 60); if (minutes == 0) { @@ -35,7 +36,7 @@ public String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberO if (numberOfParticipants == 0) { throw new GlobalException(GlobalErrorCode.NO_PARTICIPANTS); } - + List meetingTodoList = new ArrayList<>(); Field[] fields = pmRequestDTO.getClass().getDeclaredFields(); StringBuilder todo = new StringBuilder(); StringBuilder todoFormat = new StringBuilder(); @@ -44,6 +45,7 @@ public String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberO field.setAccessible(true); try { boolean value = field.getBoolean(pmRequestDTO); + meetingTodoList.add(value); if (value) { todo.append(MeetingTodo.fromValue(field.getName())).append("\n"); todoFormat.append(MeetingTodo.fromValue(field.getName())).append(":00분\n"); @@ -62,7 +64,22 @@ public String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberO + "에 대해서 시간 분배를 해줘. 다른것 추가하지 말고 아래의 형식대로만 보내줘\n" + todoFormat; - return chatGptService.recommendMeetingToDo(query); + String result = chatGptService.recommendMeetingToDo(query); + + List timeList = new ArrayList<>(); + String[] split = result.split("\n"); + int cnt = 0; + for (Boolean meetingTodo : meetingTodoList) { + if (!meetingTodo) { + timeList.add(-1L); + } else { + String s = split[cnt]; + String second = s.replaceAll("[^0-9]", ""); + timeList.add(Long.parseLong(second) * 60000); + cnt++; + } + } + return timeList; } public String summarize(MultipartFile file) {