Skip to content

Commit

Permalink
fix: faultrate 산출 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mangowhoiscloud committed Nov 8, 2024
1 parent d1c58c6 commit b4270cc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ResponseEntity<DataResponse<Void>> deleteMember(@RequestBody DeleteMember

@PostMapping("/profile/presigned")
public ResponseEntity<DataResponse<CreatePresignedUrlResponse>> createProfileImagePreSignedUrl(
@RequestBody CreateProfileImageUrlRequest request) {
@Valid @RequestBody CreateProfileImageUrlRequest request) {
return ResponseEntity.status(HttpStatus.CREATED)
.body(DataResponse.created(s3Service.createProfilePresignedUrl(request)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import aimo.backend.domains.privatePost.service.ChatRecordService;
import aimo.backend.domains.privatePost.service.PrivatePostService;

import aimo.backend.infrastructure.s3.S3Service;
import aimo.backend.infrastructure.s3.dto.request.CreatePresignedUrlRequest;
import aimo.backend.infrastructure.s3.dto.response.CreatePresignedUrlResponse;
import jakarta.validation.Valid;
Expand All @@ -52,6 +53,7 @@ public class PrivatePostController {
private final PrivatePostService privatePostService;
private final TextRecordService textRecordService;
private final ChatRecordService chatRecordService;
private final S3Service s3Service;

// 판결
@PostMapping("/judgement")
Expand Down Expand Up @@ -91,7 +93,7 @@ public ResponseEntity<DataResponse<SpeechToTextResponse>> speechToText(
public ResponseEntity<DataResponse<CreatePresignedUrlResponse>> getPresignedUrlTo(
@Valid @RequestBody CreatePresignedUrlRequest createPresignedUrlRequest) {
return ResponseEntity.status(HttpStatus.CREATED)
.body(DataResponse.created(audioRecordService.createPresignedUrl(createPresignedUrlRequest)));
.body(DataResponse.created(s3Service.createAudioPreSignedUrl(createPresignedUrlRequest)));
}

@PostMapping("/audio/success")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ public class AudioRecordService {
private final WebClient webClient;
private final AiServerProperties aiServerProperties;

public CreatePresignedUrlResponse createPresignedUrl(CreatePresignedUrlRequest createPresignedUrlRequest) {
String url = s3Service.createAudioPreSignedUrl(createPresignedUrlRequest);
String filename = createPresignedUrlRequest.filename();
String extension = filename.substring(filename.lastIndexOf(".") + 1);

if (!isAudioFile(extension)) {
throw ApiException.from(ErrorCode.INVALID_FILE_EXTENSION);
}

return new CreatePresignedUrlResponse(url, filename);
}

public SpeechToTextResponse speechToText(SpeechToTextRequest speechToTextRequest) {
return webClient.post()
.uri(aiServerProperties.getDomainUrl() + aiServerProperties.getSpeechToTextApi())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public JudgementResponse serveScriptToAi(JudgementToAiRequest judgementToAiReque
judgementFromAi.stancePlaintiff(),
judgementFromAi.stanceDefendant(),
judgementFromAi.judgement(),
faultRatePlaintiff,
faultRateDefendant,
100 - faultRatePlaintiff,
100 - faultRateDefendant,
judgementToAiRequest.originType());
})
.block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public class S3Service {
private final AmazonS3 amazonS3Client;
private final S3Properties s3Properties;

public String createAudioPreSignedUrl(CreatePresignedUrlRequest request) {
public CreatePresignedUrlResponse createAudioPreSignedUrl(CreatePresignedUrlRequest request) {
String path = createPath(PresignedUrlPrefix.AUDIO.getValue(), request.filename());
return createGeneratePresignedUrlRequest(path);
String url = createGeneratePresignedUrlRequest(path);
return new CreatePresignedUrlResponse(url, request.filename());
}

public CreatePresignedUrlResponse createProfilePresignedUrl(CreateProfileImageUrlRequest request) {
Expand Down

0 comments on commit b4270cc

Please sign in to comment.