-
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.
Merge branch 'develop' of https://github.com/Team-Tiki/TIKI_SERVER in…
…to feat/#177-kick-out-member
- Loading branch information
Showing
24 changed files
with
479 additions
and
82 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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/tiki/server/document/adapter/DeletedDocumentAdapter.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,47 @@ | ||
package com.tiki.server.document.adapter; | ||
|
||
import static com.tiki.server.document.message.ErrorCode.INVALID_DOCUMENT; | ||
|
||
import java.util.List; | ||
|
||
import com.tiki.server.common.support.RepositoryAdapter; | ||
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.document.repository.DeletedDocumentRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RepositoryAdapter | ||
@RequiredArgsConstructor | ||
public class DeletedDocumentAdapter { | ||
|
||
private final DeletedDocumentRepository deletedDocumentRepository; | ||
|
||
public List<DeletedDocument> get(final long teamId) { | ||
return deletedDocumentRepository.findAllByTeamId(teamId); | ||
} | ||
|
||
public void save(final List<Document> documents) { | ||
documents.forEach(document -> deletedDocumentRepository.save(create(document, document.getTeamId()))); | ||
} | ||
|
||
public List<DeletedDocument> get(final List<Long> deletedDocumentIds, final long teamId) { | ||
return deletedDocumentIds.stream() | ||
.map(id -> find(id, teamId)) | ||
.toList(); | ||
} | ||
|
||
public void deleteAll(final List<DeletedDocument> deletedDocuments) { | ||
deletedDocumentRepository.deleteAll(deletedDocuments); | ||
} | ||
|
||
private DeletedDocument create(final Document document, final long teamId) { | ||
return DeletedDocument.of(document.getFileName(), document.getFileUrl(), teamId, document.getCapacity()); | ||
} | ||
|
||
private DeletedDocument find(final long id, final long teamId) { | ||
return deletedDocumentRepository.findByIdAndTeamId(id, teamId) | ||
.orElseThrow(() -> new DocumentException(INVALID_DOCUMENT)); | ||
} | ||
} |
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/com/tiki/server/document/dto/response/DeletedDocumentsGetResponse.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 com.tiki.server.document.dto.response; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
import java.util.List; | ||
|
||
import com.tiki.server.document.entity.DeletedDocument; | ||
|
||
import lombok.Builder; | ||
import lombok.NonNull; | ||
|
||
@Builder(access = PRIVATE) | ||
public record DeletedDocumentsGetResponse( | ||
List<DeletedDocumentGetResponse> deletedDocuments | ||
) { | ||
|
||
public static DeletedDocumentsGetResponse from(final List<DeletedDocument> deletedDocuments) { | ||
return DeletedDocumentsGetResponse.builder() | ||
.deletedDocuments(deletedDocuments.stream().map(DeletedDocumentGetResponse::from).toList()) | ||
.build(); | ||
} | ||
|
||
@Builder(access = PRIVATE) | ||
private record DeletedDocumentGetResponse( | ||
long documentId, | ||
@NonNull String name, | ||
@NonNull String url, | ||
double capacity | ||
) { | ||
|
||
private static DeletedDocumentGetResponse from(final DeletedDocument deletedDocument) { | ||
return DeletedDocumentGetResponse.builder() | ||
.documentId(deletedDocument.getId()) | ||
.name(deletedDocument.getFileName()) | ||
.url(deletedDocument.getFileUrl()) | ||
.capacity(deletedDocument.getCapacity()) | ||
.build(); | ||
} | ||
} | ||
} |
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.