Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7f3ac88
feat(Subscribe): 구독 모델 추가
Chan531 Dec 4, 2024
ecfaa4d
feat(Team): 구독 모델 컬럼 추가
Chan531 Dec 4, 2024
34bf179
chore(Team): 메소드명 수정
Chan531 Dec 4, 2024
f7810c1
feat(SubscribeInfo): 구독 정보 클래스
Chan531 Dec 4, 2024
4f05969
feat(Team): 구독 정보 컬럼 추가
Chan531 Dec 4, 2024
41fc89a
refactor(SubscribeInfo): 접근 제한자 수정
Chan531 Dec 4, 2024
00dc991
feat(SuccessMessage): 팀 용량 정보 조회 성공 메세지 추가
Chan531 Dec 4, 2024
1a0925e
feat(Subscribe): getter 추가
Chan531 Dec 4, 2024
fc53d01
feat(UsageGetResponse): 팀 용량 정보 조회 dto
Chan531 Dec 4, 2024
76f359c
feat(TeamService): 팀 용량 정보 조회
Chan531 Dec 4, 2024
e66edb0
feat(TeamController): 팀 용량 정보 조회 API
Chan531 Dec 4, 2024
f8d45c4
style(TeamController): 메소드 파라미터 컨벤션 적용
Chan531 Dec 4, 2024
1ff43c2
chore(TeamControllerDocs): 스웨거 정보 추가
Chan531 Dec 4, 2024
699af0d
chore(TeamControllerDocs): 스웨거 누락 정보 추가
Chan531 Dec 4, 2024
884a0cd
chore(Team): 충돌 해결
Chan531 Dec 10, 2024
ea6f770
feat(ErrorCode): 팀 사용 용량 초과 메세지
Chan531 Dec 10, 2024
231f7b7
feat(SubscribeInfo): 팀 용량 더하기
Chan531 Dec 10, 2024
4c3892e
feat(Team): 팀 용량 더하기
Chan531 Dec 10, 2024
e03f072
feat(DocumentService): 파일 생성 시, 팀 용량 더하기 로직 추가
Chan531 Dec 10, 2024
9706141
feat(SubscribeInfo): 팀 용량 되돌리기
Chan531 Dec 10, 2024
ea350b7
feat(Team): 팀 용량 되돌리기
Chan531 Dec 10, 2024
90cdfc5
feat(DocumentService): 휴지통 지우기 시, 팀 용량 되돌리기 로직 추가
Chan531 Dec 10, 2024
8d47e75
feat(DocumentService): 파일 지우기 시, s3 url 제거 로직 추가
Chan531 Dec 10, 2024
577e171
refactor(DocumentService): 팀 용량 복구 로직 메소드 분리
Chan531 Dec 10, 2024
09bf311
refactor(DocumentService): forEach 적용
Chan531 Dec 10, 2024
e4d621d
feat(BlockType) : 타임 블록 유형 변경 적용
Chan531 Dec 10, 2024
69c9483
chore(AuthControllerDocs): 스웨거 누락 정보 수정
Chan531 Dec 10, 2024
18658b5
style(DocumentController): 불필요한 import문 제거
Chan531 Dec 10, 2024
faac45a
feat(DocumentControllerDocs): 스웨거 정보 추가
Chan531 Dec 10, 2024
06fa8a2
feat(DocumentCreateRequest): 스웨거 정보 추가
Chan531 Dec 10, 2024
67ab067
feat(FolderControllerDocs): 스웨거 정보 추가
Chan531 Dec 10, 2024
4995a03
feat(FolderNameUpdateRequest): 스웨거 정보 추가
Chan531 Dec 10, 2024
fbeb7a1
feat(FolderCreateRequest): 스웨거 정보 추가
Chan531 Dec 10, 2024
9080c0a
style: dto 컨벤션 적용
Chan531 Dec 10, 2024
5ad207d
style: dto 패키지 통일
Chan531 Dec 10, 2024
320ec1e
chore(TimeBlockControllerDocs): 스웨거 정보 추가
Chan531 Dec 10, 2024
a008f6e
style(S3Handler): 불필요한 import문 제거
Chan531 Dec 10, 2024
744e644
refactor: 사용량 및 총 용량 반환 책임 위임
Chan531 Dec 10, 2024
cb5eaa9
refactor: 팀 용량 증가 로직 이동
Chan531 Dec 11, 2024
308fa83
refactor: 구독 정보 팀으로 통합
Chan531 Dec 11, 2024
b9ff1b0
fix: 용량 getter 추가
Chan531 Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public interface AuthControllerDocs {
@ApiResponse(responseCode = "201", description = "성공"),
@ApiResponse(
responseCode = "401",
description = "유효하지 않은 키",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(
responseCode = "401",
description = "인증되지 않은 사용자",
description = "유효하지 않은 키, 인증되지 않은 사용자",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(
responseCode = "404",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.tiki.server.document.controller.docs.DocumentControllerDocs;
import com.tiki.server.document.dto.request.DocumentsCreateRequest;
import com.tiki.server.document.dto.response.DeletedDocumentsGetResponse;
import com.tiki.server.document.dto.response.DocumentsCreateResponse;
import com.tiki.server.document.dto.response.DocumentsGetResponse;
import com.tiki.server.document.service.DocumentService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.tiki.server.document.controller.docs;

import java.security.Principal;
import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.tiki.server.common.dto.ErrorResponse;
import com.tiki.server.common.dto.SuccessResponse;
import com.tiki.server.document.dto.request.DocumentsCreateRequest;
import com.tiki.server.document.dto.response.DeletedDocumentsGetResponse;
import com.tiki.server.document.dto.response.DocumentsGetResponse;

import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -50,12 +54,12 @@ ResponseEntity<SuccessResponse<DocumentsGetResponse>> getAllDocuments(
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
)
@PathVariable long teamId,
) @PathVariable long teamId,
@Parameter(
name = "type",
description = "타임라인 타입",
in = ParameterIn.QUERY,
required = true,
example = "executive, member"
) @RequestParam String type
);
Expand Down Expand Up @@ -89,14 +93,190 @@ ResponseEntity<?> deleteDocument(
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
)
@PathVariable long teamId,
) @PathVariable long teamId,
@Parameter(
name = "documentId",
description = "문서 id",
in = ParameterIn.PATH,
example = "1"
)
@PathVariable long documentId
) @PathVariable long documentId
);

@Operation(
summary = "문서 생성",
description = "문서를 여러 개 생성한다.",
responses = {
@ApiResponse(responseCode = "201", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<SuccessResponse<?>> createDocuments(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId,
@Parameter(
name = "폴더 id",
description = "생성할 파일이 속할 폴더 id",
in = ParameterIn.QUERY,
example = "1"
) @RequestParam Long folderId,
@RequestBody final DocumentsCreateRequest request
);

@Operation(
summary = "문서 조회",
description = "문서를 조회한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<SuccessResponse<DocumentsGetResponse>> getDocuments(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId,
@Parameter(
name = "폴더 id",
description = "조회할 폴더 id",
in = ParameterIn.QUERY,
example = "1"
) @RequestParam Long folderId
);

@Operation(
summary = "문서 삭제",
description = "문서를 여러 개 삭제한다.",
responses = {
@ApiResponse(responseCode = "204", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<?> delete(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId,
@Parameter(
name = "파일 id",
description = "삭제할 파일 id 리스트",
in = ParameterIn.QUERY,
required = true,
example = "[1, 2]"
) @RequestParam("documentId") List<Long> documentIds
);

@Operation(
summary = "휴지통 문서 삭제",
description = "휴지통 속 문서를 여러 개 삭제한다.",
responses = {
@ApiResponse(responseCode = "204", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<?> deleteTrash(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId,
@Parameter(
name = "파일 id",
description = "삭제할 파일 id 리스트",
in = ParameterIn.QUERY,
required = true,
example = "[1, 2]"
) @RequestParam("documentId") List<Long> deletedDocumentIds
);

@Operation(
summary = "휴지통 문서 복구",
description = "휴지통 속 문서를 여러 개 복구한다.",
responses = {
@ApiResponse(responseCode = "204", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<?> restore(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId,
@Parameter(
name = "파일 id",
description = "복구할 파일 id 리스트",
in = ParameterIn.QUERY,
required = true,
example = "[1, 2]"
) @RequestParam("documentId") List<Long> deletedDocumentIds
);

@Operation(
summary = "휴지통 조회",
description = "휴지통을 조회한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<SuccessResponse<DeletedDocumentsGetResponse>> getTrash(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "팀 id",
description = "팀 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long teamId
);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.tiki.server.document.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.NonNull;

public record DocumentCreateRequest(
@Schema(description = "파일 이름", example = "tiki.jpg")
@NonNull String fileName,
@Schema(description = "파일 url", example = "https://.../tiki.jpg")
@NonNull String fileUrl,
@Schema(description = "파일 용량", example = "1.23")
double capacity
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
import com.tiki.server.document.entity.DeletedDocument;
import com.tiki.server.document.entity.Document;
import com.tiki.server.document.exception.DocumentException;
import com.tiki.server.external.util.S3Handler;
import com.tiki.server.folder.adapter.FolderFinder;
import com.tiki.server.folder.entity.Folder;
import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder;
import com.tiki.server.memberteammanager.entity.MemberTeamManager;
import com.tiki.server.team.adapter.TeamFinder;
import com.tiki.server.team.entity.Team;

import lombok.RequiredArgsConstructor;

Expand All @@ -37,6 +40,8 @@ public class DocumentService {
private final FolderFinder folderFinder;
private final MemberTeamManagerFinder memberTeamManagerFinder;
private final DeletedDocumentAdapter deletedDocumentAdapter;
private final TeamFinder teamFinder;
private final S3Handler s3Handler;

public DocumentsGetResponse getAllDocuments(final long memberId, final long teamId, final String type) {
MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId);
Expand Down Expand Up @@ -80,6 +85,8 @@ public void delete(final long memberId, final long teamId, final List<Long> docu
public void deleteTrash(final long memberId, final long teamId, final List<Long> documentIds) {
memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId);
List<DeletedDocument> deletedDocuments = deletedDocumentAdapter.get(documentIds, teamId);
restoreTeamUsage(teamId, deletedDocuments);
deletedDocuments.forEach(deletedDocument -> s3Handler.deleteFile(deletedDocument.getFileName()));
deletedDocumentAdapter.deleteAll(deletedDocuments);
}

Expand Down Expand Up @@ -122,12 +129,21 @@ private void checkFileNameIsDuplicated(final String fileName, final DocumentsCre
}

private void saveDocuments(final long teamId, final Long folderId, final DocumentsCreateRequest request) {
request.documents().forEach(document -> saveDocument(teamId, folderId, document));
Team team = teamFinder.findById(teamId);
request.documents().forEach(document -> {
team.addUsage(document.capacity());
saveDocument(teamId, folderId, document);
});
}

private void saveDocument(final long teamId, final Long folderId, final DocumentCreateRequest request) {
Document document = Document.of(
request.fileName(), request.fileUrl(), request.capacity(), teamId, folderId);
documentSaver.save(document);
}

private void restoreTeamUsage(final long teamId, final List<DeletedDocument> deletedDocuments) {
Team team = teamFinder.findById(teamId);
team.restoreUsage(deletedDocuments.stream().mapToDouble(DeletedDocument::getCapacity).sum());
}
}
1 change: 0 additions & 1 deletion src/main/java/com/tiki/server/external/util/S3Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.stereotype.Component;

import com.tiki.server.external.config.AWSConfig;
import com.tiki.server.external.dto.request.S3DeleteRequest;
import com.tiki.server.external.dto.response.PreSignedUrlResponse;
import com.tiki.server.external.exception.ExternalException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.tiki.server.common.dto.SuccessResponse;
import com.tiki.server.common.support.UriGenerator;
import com.tiki.server.folder.controller.docs.FolderControllerDocs;
import com.tiki.server.folder.dto.request.FolderCreateRequest;
import com.tiki.server.folder.dto.request.FolderNameUpdateRequest;
import com.tiki.server.folder.dto.response.FolderCreateResponse;
Expand All @@ -32,7 +33,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("api/v1")
public class FolderController {
public class FolderController implements FolderControllerDocs {

private final FolderService folderService;

Expand Down
Loading
Loading