-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
pdf 기능 구현
- Loading branch information
Showing
8 changed files
with
107 additions
and
26 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
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/smart/watchboard/controller/LearningFileController.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,49 @@ | ||
package com.smart.watchboard.controller; | ||
|
||
import com.smart.watchboard.common.support.AwsS3Uploader; | ||
import com.smart.watchboard.dto.FileDto; | ||
import com.smart.watchboard.dto.S3Dto; | ||
import com.smart.watchboard.service.FileService; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import javax.sound.sampled.UnsupportedAudioFileException; | ||
import java.io.IOException; | ||
|
||
@RestController | ||
@RequestMapping("/documents") | ||
@Tag(name = "pdf 학습파일 API", description = "학습파일 관련 API(mock)") | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class LearningFileController { | ||
private final AwsS3Uploader awsS3Uploader; | ||
private final FileService fileService; | ||
|
||
@PostMapping("/{documentID}/pdf") | ||
public ResponseEntity<?> uploadLearningFile(@PathVariable(value = "documentID") long documentId, @RequestParam("pdfFile") MultipartFile pdfFile, @RequestParam(value = "fileID", required = false) Long fileId, @RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { | ||
S3Dto s3Dto = new S3Dto(pdfFile, documentId, fileId); | ||
awsS3Uploader.uploadFile(s3Dto); | ||
|
||
return new ResponseEntity<>("", HttpStatus.OK); | ||
} | ||
|
||
@PutMapping("/{documentID}/pdf") | ||
public ResponseEntity<?> updateLearningFile(@PathVariable(value = "documentID") long documentId, @RequestParam("pdfFile") MultipartFile pdfFile, @RequestParam(value = "fileID", required = false) Long fileId, @RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { | ||
S3Dto s3Dto = new S3Dto(pdfFile, documentId, fileId); | ||
awsS3Uploader.uploadFile(s3Dto); | ||
|
||
return new ResponseEntity<>("", HttpStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{documentID}/pdf") | ||
public ResponseEntity<?> deleteLearningFile(@PathVariable(value = "documentID") long documentId, @RequestParam(value = "fileID", required = false) Long fileId, @RequestHeader("Authorization") String accessToken) throws UnsupportedAudioFileException, IOException { | ||
fileService.deleteFile(fileId); | ||
|
||
return new ResponseEntity<>("", HttpStatus.OK); | ||
} | ||
} |
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
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,21 @@ | ||
package com.smart.watchboard.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Getter | ||
@Setter | ||
@RequiredArgsConstructor | ||
public class S3Dto { | ||
private MultipartFile file; | ||
private Long documentId; | ||
private Long fileId; | ||
|
||
public S3Dto(MultipartFile file, long documentId, Long fileId) { | ||
this.file = file; | ||
this.documentId = documentId; | ||
this.fileId = fileId; | ||
} | ||
} |
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