-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
433e813
commit 360e59a
Showing
21 changed files
with
227 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
...c/main/java/aimo/backend/domains/privatePost/dto/parameter/SaveAudioSuccessParameter.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...c/main/java/aimo/backend/domains/privatePost/dto/request/AudioRecordPresignedRequest.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...main/java/aimo/backend/domains/privatePost/dto/response/AudioRecordPresignedResponse.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...src/main/java/aimo/backend/domains/privatePost/dto/response/SaveAudioSuccessResponse.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
backend/src/main/java/aimo/backend/domains/privatePost/service/AudioRecordService.java
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
backend/src/main/java/aimo/backend/domains/upload/controller/AudioController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package aimo.backend.domains.upload.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import aimo.backend.common.dto.DataResponse; | ||
import aimo.backend.domains.upload.dto.parameter.CreateAudioPreSignedUrlParameter; | ||
import aimo.backend.domains.upload.dto.parameter.SaveAudioMetaDataParameter; | ||
import aimo.backend.domains.upload.dto.request.SaveAudioMetaDataRequest; | ||
import aimo.backend.domains.upload.dto.response.SaveAudioMetaDataResponse; | ||
import aimo.backend.domains.upload.service.AudioRecordService; | ||
import aimo.backend.infrastructure.s3.dto.request.CreatePreSignedUrlRequest; | ||
import aimo.backend.infrastructure.s3.dto.response.CreatePreSignedUrlResponse; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/audio") | ||
public class AudioController { | ||
|
||
private final AudioRecordService audioRecordService; | ||
|
||
@PostMapping | ||
public ResponseEntity<DataResponse<SaveAudioMetaDataResponse>> saveAudioMetaData( | ||
@Valid @RequestBody SaveAudioMetaDataRequest request | ||
) { | ||
SaveAudioMetaDataParameter parameter = SaveAudioMetaDataParameter.from(request); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED) | ||
.body(DataResponse.created(audioRecordService.save(parameter))); | ||
} | ||
|
||
@GetMapping("/presigned/{filename}") | ||
public ResponseEntity<DataResponse<CreatePreSignedUrlResponse>> createAudioPreSignedUrl( | ||
@Valid @RequestBody CreatePreSignedUrlRequest request | ||
) { | ||
CreateAudioPreSignedUrlParameter parameter = CreateAudioPreSignedUrlParameter.of(request.filename()); | ||
|
||
CreatePreSignedUrlResponse response = audioRecordService.createAudioPreSignedUrl(parameter); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED) | ||
.body(DataResponse.created(response)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/aimo/backend/domains/upload/dto/parameter/CreateAudioPreSignedUrlParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package aimo.backend.domains.upload.dto.parameter; | ||
|
||
public record CreateAudioPreSignedUrlParameter(String filename, String extension) { | ||
|
||
public static CreateAudioPreSignedUrlParameter of(String filename) { | ||
String extension = filename.substring(filename.lastIndexOf(".") + 1); | ||
|
||
return new CreateAudioPreSignedUrlParameter(filename, extension); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...d/src/main/java/aimo/backend/domains/upload/dto/parameter/SaveAudioMetaDataParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package aimo.backend.domains.upload.dto.parameter; | ||
|
||
import aimo.backend.domains.upload.dto.request.SaveAudioMetaDataRequest; | ||
|
||
public record SaveAudioMetaDataParameter( | ||
String url, | ||
Long size, | ||
String filename, | ||
String extension | ||
) { | ||
|
||
public static SaveAudioMetaDataParameter from(SaveAudioMetaDataRequest request) { | ||
return new SaveAudioMetaDataParameter( | ||
request.url(), | ||
request.size(), | ||
request.filename(), | ||
request.extension() | ||
); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
.../dto/parameter/SpeechToTextParameter.java → .../dto/parameter/SpeechToTextParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Post/dto/request/SpeechToTextRequest.java → ...load/dto/request/SpeechToTextRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...end/src/main/java/aimo/backend/domains/upload/dto/response/SaveAudioMetaDataResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package aimo.backend.domains.upload.dto.response; | ||
|
||
import aimo.backend.domains.privatePost.entity.AudioRecord; | ||
|
||
public record SaveAudioMetaDataResponse( | ||
String url, | ||
Long size, | ||
String filename | ||
) { | ||
|
||
public static SaveAudioMetaDataResponse of(String url, Long size, String filename) { | ||
return new SaveAudioMetaDataResponse(url, size, filename); | ||
} | ||
|
||
public static SaveAudioMetaDataResponse from(AudioRecord audioRecord) { | ||
return new SaveAudioMetaDataResponse( | ||
audioRecord.getUrl(), | ||
audioRecord.getSize(), | ||
audioRecord.getFilename() | ||
); | ||
} | ||
} |
Oops, something went wrong.