-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/haeun step3 #10
Open
pear96
wants to merge
15
commits into
base/haeun
Choose a base branch
from
feature/haeun_step3
base: base/haeun
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2184277
refactor: DTO 폴더 분리
pear96 33c25d5
feat : 파일 이동 구현
pear96 e1be1e6
feat : 폴더 이동, 삭제 구현
pear96 71da387
feat : 이동, 삭제에 필요한 DTO, Repository
pear96 89de494
test : 폴더 이동, 삭제, 파일 이동 테스트 코드 작성
pear96 ad35811
style : 주석 수정 및 코드 스타일 수정
pear96 4724bb6
refactor : 자잘한 수정
pear96 c207e3f
refactor : DTO의 long 필드 유효성 검사 수정
pear96 dd8c115
refactor : 폴더의 하위 폴더, 파일 목록 조회 DTO 추가
pear96 bbde742
refactor : Validation 관련 에러 메세지 핸들러 추가
pear96 2e85d49
refactor : fileService의 private Method 테스트
pear96 d9796b0
style : 코드 스타일에 맞춰 수정
pear96 7d48a93
refactor : Pageable 객체 서버 내부 생성
pear96 3f2c19c
fix : 코드 오류 수정
pear96 230ce8d
fix : 코드 오류 수정
pear96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package com.c4cometrue.mystorage.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
@@ -10,11 +14,15 @@ | |
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.c4cometrue.mystorage.dto.request.CreateFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.GetFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.UpdateFolderNameReq; | ||
import com.c4cometrue.mystorage.dto.response.CreateFolderRes; | ||
import com.c4cometrue.mystorage.dto.response.FolderOverviewRes; | ||
import com.c4cometrue.mystorage.dto.request.folder.CreateFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.folder.DeleteFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.folder.GetFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.folder.MoveFolderReq; | ||
import com.c4cometrue.mystorage.dto.request.folder.UpdateFolderNameReq; | ||
import com.c4cometrue.mystorage.dto.response.file.FileMetaDataRes; | ||
import com.c4cometrue.mystorage.dto.response.folder.CreateFolderRes; | ||
import com.c4cometrue.mystorage.dto.response.folder.FolderMetaDataRes; | ||
import com.c4cometrue.mystorage.dto.response.folder.FolderOverviewRes; | ||
import com.c4cometrue.mystorage.service.FolderService; | ||
|
||
import jakarta.validation.Valid; | ||
|
@@ -31,18 +39,42 @@ public class FolderController { | |
/** | ||
* 폴더의 개략적인 정보 요청 | ||
* @param req (폴더 기본키, 폴더 이름, 사용자 이름, 부모 폴더 기본키) | ||
* @return {@link com.c4cometrue.mystorage.dto.response.FolderOverviewRes} | ||
* @return {@link FolderOverviewRes} | ||
*/ | ||
@GetMapping | ||
@ResponseStatus(HttpStatus.OK) | ||
public FolderOverviewRes getFolderData(@Valid GetFolderReq req) { | ||
return folderService.getFolderData(req.folderId(), req.userName()); | ||
return folderService.getFolderTotalInfo(req.folderId(), req.userName()); | ||
} | ||
|
||
/** | ||
* 폴더의 하위 폴더들을 페이징으로 조회 | ||
* @param folderId 폴더 기본키 | ||
* @param pageable paging을 위한 파라미터 | ||
* @return page 번호에 맞는 하위 폴더 목록 | ||
*/ | ||
@GetMapping("/subFolder") | ||
@ResponseStatus(HttpStatus.OK) | ||
public List<FolderMetaDataRes> getSubFolders(long folderId, Pageable pageable) { | ||
return folderService.getFolders(folderId, pageable.getPageNumber()); | ||
} | ||
|
||
/** | ||
* 폴더의 하위 파일들을 페이징으로 조회 | ||
* @param folderId 폴더 기본키 | ||
* @param pageable paging을 위한 파라미터 | ||
* @return page 번호에 맞는 하위 파일 목록 | ||
*/ | ||
@GetMapping("/subFile") | ||
@ResponseStatus(HttpStatus.OK) | ||
public List<FileMetaDataRes> getSubFiles(long folderId, Pageable pageable) { | ||
return folderService.getFiles(folderId, pageable.getPageNumber()); | ||
} | ||
|
||
/** | ||
* 폴더 생성 요청이 성공하면 해당 폴더 pk를 포함한 정보 반환 | ||
* @param req (폴더 이름, 사용자 이름, 부모 폴더 기본키) | ||
* @return {@link com.c4cometrue.mystorage.dto.response.CreateFolderRes} | ||
* @param req (폴더 기본키, 사용자 이름, 부모 폴더 기본키) | ||
* @return {@link CreateFolderRes} | ||
*/ | ||
@PostMapping | ||
@ResponseStatus(HttpStatus.CREATED) | ||
|
@@ -51,13 +83,33 @@ public CreateFolderRes createFolder(@RequestBody @Valid CreateFolderReq req) { | |
} | ||
|
||
/** | ||
* 폴더 이름 수정 요청 | ||
* @param updateFolderNameReq (이전 폴더 이름, 사용자 이름, 새로운 폴더 이름, 부모 폴더 기본키) | ||
* 폴더 이름을 수정하는 요청 | ||
* @param req (폴더 기본키, 부모 폴더 기본키, 사용자 이름, 새로운 폴더 이름) | ||
*/ | ||
@PatchMapping("/name") | ||
@ResponseStatus(HttpStatus.OK) | ||
public void updateFolderName(@RequestBody @Valid UpdateFolderNameReq updateFolderNameReq) { | ||
folderService.updateFolderName(updateFolderNameReq.folderId(), updateFolderNameReq.parentFolderId(), | ||
updateFolderNameReq.userName(), updateFolderNameReq.newFolderName()); | ||
public void updateFolderName(@RequestBody @Valid UpdateFolderNameReq req) { | ||
folderService.updateFolderName(req.folderId(), req.parentFolderId(), | ||
req.userName(), req.newFolderName()); | ||
} | ||
|
||
/** | ||
* 폴더를 삭제하는 요청 | ||
* @param req (폴더 기본키) | ||
*/ | ||
@DeleteMapping | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void deleteFolder(@RequestBody @Valid DeleteFolderReq req) { | ||
folderService.deleteFolder(req.folderId(), req.userName()); | ||
} | ||
|
||
/** | ||
* 폴더를 특정 폴더 위치로 이동하는 요청 | ||
* @param req (폴더 기본키, 이동할 폴더 기본키, 사용자 이름) | ||
*/ | ||
@PatchMapping | ||
@ResponseStatus(HttpStatus.MOVED_PERMANENTLY) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MOVED_PERMANENTLY는 리다이렉트를 위한 HttpStatusCode입니다. |
||
public void moveFolder(@RequestBody @Valid MoveFolderReq req) { | ||
folderService.moveFolder(req.folderId(), req.targetFolderId(), req.userName()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.c4cometrue.mystorage.dto.request; | ||
package com.c4cometrue.mystorage.dto.request.file; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
|
@@ -7,7 +7,7 @@ | |
* @see com.c4cometrue.mystorage.entity.FileMetaData | ||
*/ | ||
public record FileReq( | ||
@NotBlank(message = "file storage name is blank") String fileStorageName, | ||
@NotNull(message = "file id is blank") long fileId, | ||
@NotBlank(message = "user name is blank") String userName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전체적인 로직을 고려했을 때, |
||
@NotNull(message = "folder id is blank") long folderId | ||
) { | ||
|
14 changes: 14 additions & 0 deletions
14
src/main/java/com/c4cometrue/mystorage/dto/request/file/MoveFileReq.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,14 @@ | ||
package com.c4cometrue.mystorage.dto.request.file; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* DTO for {@link com.c4cometrue.mystorage.entity.FileMetaData} | ||
*/ | ||
public record MoveFileReq( | ||
@NotNull(message = "file id is blank") long fileId, | ||
@NotNull(message = "folder id is blank") long folderId, | ||
@NotBlank(message = "user name is blank") String userName | ||
) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...true/mystorage/dto/request/SignUpReq.java → ...mystorage/dto/request/file/SignUpReq.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
2 changes: 1 addition & 1 deletion
2
.../mystorage/dto/request/UploadFileReq.java → ...orage/dto/request/file/UploadFileReq.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
2 changes: 1 addition & 1 deletion
2
...ystorage/dto/request/CreateFolderReq.java → ...e/dto/request/folder/CreateFolderReq.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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/c4cometrue/mystorage/dto/request/folder/DeleteFolderReq.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,12 @@ | ||
package com.c4cometrue.mystorage.dto.request.folder; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* @see com.c4cometrue.mystorage.entity.FolderMetaData | ||
*/ | ||
public record DeleteFolderReq( | ||
@NotNull(message = "folder id can't be null") long folderId, | ||
@NotBlank(message = "user name is blank") String userName) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...e/mystorage/dto/request/GetFolderReq.java → ...rage/dto/request/folder/GetFolderReq.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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/c4cometrue/mystorage/dto/request/folder/MoveFolderReq.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,14 @@ | ||
package com.c4cometrue.mystorage.dto.request.folder; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* @see com.c4cometrue.mystorage.entity.FolderMetaData | ||
*/ | ||
public record MoveFolderReq( | ||
@NotNull(message = "folder id can't be null") long folderId, | ||
@NotNull(message = "target folder can't be null") long targetFolderId, | ||
@NotBlank(message = "user name is blank") String userName | ||
) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...rage/dto/request/UpdateFolderNameReq.java → ...o/request/folder/UpdateFolderNameReq.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
2 changes: 1 addition & 1 deletion
2
...storage/dto/response/FileDownloadRes.java → ...ge/dto/response/file/FileDownloadRes.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
2 changes: 1 addition & 1 deletion
2
...storage/dto/response/FileMetaDataRes.java → ...ge/dto/response/file/FileMetaDataRes.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
...orage/dto/response/FolderMetaDataRes.java → ...to/response/folder/FolderMetaDataRes.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
4 changes: 3 additions & 1 deletion
4
...orage/dto/response/FolderOverviewRes.java → ...to/response/folder/FolderOverviewRes.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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/c4cometrue/mystorage/entity/DeleteLog.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 com.c4cometrue.mystorage.entity; | ||
|
||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Entity | ||
@RequiredArgsConstructor | ||
public class DeleteLog { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long logId; | ||
|
||
@NotBlank(message = "file storage name is blank") | ||
private String fileStorageName; | ||
|
||
@NotNull | ||
private ZonedDateTime deleteTime; | ||
|
||
public DeleteLog(String fileStorageName) { | ||
this.fileStorageName = fileStorageName; | ||
this.deleteTime = ZonedDateTime.now(ZoneId.of("Asia/Seoul")); | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
folderId는 어디서 주입받나요?