Skip to content

Commit

Permalink
Merge pull request #132 from SSU-Plector/issue/127-refactor-string-to…
Browse files Browse the repository at this point in the history
…-int

♻️ [Refactor] 회의 진행 반환 값 String에서 시간(ms)만 추출해 리턴
  • Loading branch information
88dldl authored Jul 10, 2024
2 parents b99bcb5 + 1413548 commit 93effd4
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/main/java/ssuPlector/controller/PmController.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package ssuPlector.controller;

import java.util.List;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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;

Expand All @@ -20,12 +24,12 @@ public class PmController {

@Operation(summary = "회의 진행", description = "입력 값을 받아 회의 진행을 추천합니다._숙희")
@GetMapping("/meeting")
public ApiResponse<String> recommendMeetingProgress(
public ApiResponse<PmResponseDTO> 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<Long> meeting = pmService.recommendMeeting(pmRequestDTO, time, numberOfParticipants);
return ApiResponse.onSuccess("회의 진행 추천 완료", PmConverter.toPmResponseDTO(meeting));
}

@Operation(summary = "음성 회의록 정리", description = "음성 회의록을 정리 요약합니다._찬민")
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/ssuPlector/converter/PmConverter.java
Original file line number Diff line number Diff line change
@@ -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<Long> 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();
}
}
23 changes: 23 additions & 0 deletions src/main/java/ssuPlector/dto/response/PmDTO.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 3 additions & 1 deletion src/main/java/ssuPlector/service/pm/PmService.java
Original file line number Diff line number Diff line change
@@ -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<Long> recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberOfParticipants);

String summarize(MultipartFile file);
}
23 changes: 20 additions & 3 deletions src/main/java/ssuPlector/service/pm/PmServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> recommendMeeting(
PmRequestDTO pmRequestDTO, long time, int numberOfParticipants) {
long minutes = time / (1000 * 60);

if (minutes == 0) {
Expand All @@ -35,7 +36,7 @@ public String recommendMeeting(PmRequestDTO pmRequestDTO, long time, int numberO
if (numberOfParticipants == 0) {
throw new GlobalException(GlobalErrorCode.NO_PARTICIPANTS);
}

List<Boolean> meetingTodoList = new ArrayList<>();
Field[] fields = pmRequestDTO.getClass().getDeclaredFields();
StringBuilder todo = new StringBuilder();
StringBuilder todoFormat = new StringBuilder();
Expand All @@ -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");
Expand All @@ -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<Long> 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) {
Expand Down

0 comments on commit 93effd4

Please sign in to comment.