Skip to content

Commit

Permalink
Merge pull request #111 from KUSITMS-MOAMOA/chore/#110
Browse files Browse the repository at this point in the history
[Chore/#110] 경험 기록 내용이 충분하지 않을 시 Error 반환
  • Loading branch information
daeun084 authored Nov 25, 2024
2 parents baee5b8 + 70256b7 commit 0657c22
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ private AnalysisAiResponse generateAbilityAnalysis(String content) {

private String generateMemoSummary(String content) {
String response = openAiService.generateMemoSummary(content);

validIsRecordEnough(response);
validAnalysisContentLength(response);

return response;
Expand All @@ -188,6 +190,11 @@ private String getRecordContent(Record record) {
return content;
}

private void validIsRecordEnough(String response) {
if (response.contains("NO_RECORD"))
throw new RecordException(RecordErrorStatus.NO_RECORD);
}

private void validIsUserAuthorizedForAnalysis(User user, Analysis analysis) {
if (!analysis.getRecord().getUser().equals(user))
throw new RecordException(RecordErrorStatus.USER_RECORD_UNAUTHORIZED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public RecordResponse.MemoRecordDto createMemoRecord(Long userId, RecordRequest.

// 경험 기록 종류에 따른 Record 생성
Record record = createRecordBasedOnType(recordDto, user, folder);
recordDbService.saveRecord(record);

// 역량 분석 레포트 생성
analysisService.createAnalysis(record, user);
recordDbService.saveRecord(record);

return RecordConverter.toMemoRecordDto(record);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum RecordErrorStatus implements BaseErrorStatus {
NOT_ENOUGH_MEMO_RECORD_CONTENT(HttpStatus.BAD_REQUEST, "E0400_NOT_ENOUGH_CONTENT", "메모 내용은 30자 이상이어야 합니다."),
USER_RECORD_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "E401_RECORD_UNAUTHORIZED", "유저가 경험 기록에 대한 권한이 없습니다."),
RECORD_NOT_FOUND(HttpStatus.NOT_FOUND, "E0404_RECORD", "존재하지 않는 경험 기록입니다."),
ALREADY_TMP_MEMO(HttpStatus.BAD_REQUEST, "E0400_TMP_MEMO", "유저가 이미 임시 저장된 메모를 가지고 있습니다.")
ALREADY_TMP_MEMO(HttpStatus.BAD_REQUEST, "E0400_TMP_MEMO", "유저가 이미 임시 저장된 메모를 가지고 있습니다."),
NO_RECORD(HttpStatus.BAD_REQUEST, "E0400_NO_RECORD", "경험 기록의 내용이 충분하지 않습니다.")
;

private final HttpStatus httpStatus;
Expand Down

0 comments on commit 0657c22

Please sign in to comment.