-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
24 changed files
with
240 additions
and
59 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
13 changes: 0 additions & 13 deletions
13
src/main/java/site/katchup/katchupserver/api/card/dto/response/FileGetResponseDto.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/main/java/site/katchup/katchupserver/api/card/repository/FileRepository.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
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
40 changes: 40 additions & 0 deletions
40
src/main/java/site/katchup/katchupserver/api/file/controller/FileController.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,40 @@ | ||
package site.katchup.katchupserver.api.file.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
import site.katchup.katchupserver.api.file.dto.request.FileGetPreSignedRequestDto; | ||
import site.katchup.katchupserver.api.file.dto.response.FileGetPreSignedResponseDto; | ||
import site.katchup.katchupserver.api.file.service.FileService; | ||
import site.katchup.katchupserver.common.dto.ApiResponseDto; | ||
import site.katchup.katchupserver.common.util.MemberUtil; | ||
|
||
import java.security.Principal; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
@Tag(name = "[File] 파일 관련 API (V1)") | ||
public class FileController { | ||
private final FileService fileService; | ||
|
||
@Operation(summary = "파일 Presigned-Url 요청 API") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "파일 Presigned-Url 요청 성공"), | ||
@ApiResponse(responseCode = "400", description = "파일 Presigned-Url 요청 실패", content = @Content), | ||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) | ||
} | ||
) | ||
@PostMapping("/files/presigned") | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<FileGetPreSignedResponseDto> createPresigned(Principal principal, @RequestBody FileGetPreSignedRequestDto presignedRequestDto | ||
) { | ||
Long memberId = MemberUtil.getMemberId(principal); | ||
return ApiResponseDto.success(fileService.getFilePreSignedUrl(memberId, presignedRequestDto)); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/site/katchup/katchupserver/api/file/dto/request/FileCreateRequestDto.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,31 @@ | ||
package site.katchup.katchupserver.api.file.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Schema(description = "파일 업로드 요청 DTO") | ||
public class FileCreateRequestDto { | ||
|
||
@Schema(description = "업로드하는 파일 고유 UUID", example = "ddwd-wdwd-wdwd-wdwdwdwd") | ||
@NotNull | ||
private UUID fileUUID; | ||
|
||
@Schema(description = "파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
@NotNull | ||
private String fileName; | ||
|
||
@Schema(description = "파일 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.pdf") | ||
@NotNull | ||
private String fileUrl; | ||
|
||
@Schema(description = "파일 사이즈", example = "2.1") | ||
@NotNull | ||
private Double size; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...main/java/site/katchup/katchupserver/api/file/dto/request/FileGetPreSignedRequestDto.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,19 @@ | ||
package site.katchup.katchupserver.api.file.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = PRIVATE) | ||
@Schema(description = "파일 Presigned-Url 요청 DTO") | ||
public class FileGetPreSignedRequestDto { | ||
@Schema(description = "업로드하는 파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
@NotNull | ||
private String fileName; | ||
} |
24 changes: 24 additions & 0 deletions
24
...in/java/site/katchup/katchupserver/api/file/dto/response/FileGetPreSignedResponseDto.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,24 @@ | ||
package site.katchup.katchupserver.api.file.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = PRIVATE) | ||
@AllArgsConstructor(staticName = "of") | ||
@Schema(description = "파일 PreSigned-Url 응답 DTO") | ||
public class FileGetPreSignedResponseDto { | ||
|
||
@Schema(description = "파일 UUID", example = "file-uuid") | ||
private String fileUUID; | ||
|
||
@Schema(description = "파일 이름", example = "file-name") | ||
private String fileName; | ||
|
||
@Schema(description = "파일 PreSigned-Url", example ="preSigned-url") | ||
private String filePreSignedUrl; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/site/katchup/katchupserver/api/file/dto/response/FileGetResponseDto.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,23 @@ | ||
package site.katchup.katchupserver.api.file.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@AllArgsConstructor(staticName = "of") | ||
public class FileGetResponseDto { | ||
@Schema(description = "파일 고유 id", example = "ddwd-wdwd-wdwd-wdwdwdwd") | ||
private UUID id; | ||
|
||
@Schema(description = "파일 이름", example = "와이어프레임 및 드라이브 사용법.pdf") | ||
private String name; | ||
|
||
@Schema(description = "파일 url", example = "https://abde.s3.ap-northeast-2.amazonaws.com/1.png") | ||
private String url; | ||
|
||
@Schema(description = "파일 사이즈", example = "2.1") | ||
private Double size; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/site/katchup/katchupserver/api/file/repository/FileRepository.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 site.katchup.katchupserver.api.file.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import site.katchup.katchupserver.api.file.domain.File; | ||
import site.katchup.katchupserver.api.screenshot.domain.Screenshot; | ||
import site.katchup.katchupserver.common.exception.NotFoundException; | ||
import site.katchup.katchupserver.common.response.ErrorCode; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface FileRepository extends JpaRepository<File, UUID> { | ||
|
||
List<File> findAllByCardId(Long cardId); | ||
|
||
default File findByIdOrThrow(UUID uuid) { | ||
return findById(uuid).orElseThrow( | ||
() -> new NotFoundException(ErrorCode.NOT_FOUND_FILE)); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/site/katchup/katchupserver/api/file/service/FileService.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,9 @@ | ||
package site.katchup.katchupserver.api.file.service; | ||
|
||
|
||
import site.katchup.katchupserver.api.file.dto.request.FileGetPreSignedRequestDto; | ||
import site.katchup.katchupserver.api.file.dto.response.FileGetPreSignedResponseDto; | ||
|
||
public interface FileService { | ||
FileGetPreSignedResponseDto getFilePreSignedUrl(Long memberId, FileGetPreSignedRequestDto requestDto); | ||
} |
Oops, something went wrong.