Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/main/java/com/jobnote/domain/common/BaseTimeEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ public abstract class BaseTimeEntity {

@LastModifiedDate
private LocalDateTime modifiedDate;

public void updateModifiedDate(final LocalDateTime modifiedDate) {
this.modifiedDate = modifiedDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import lombok.AccessLevel;
import lombok.Builder;

import java.time.LocalDate;

@Builder(access = AccessLevel.PRIVATE)
public record DocumentVersionResponse(
Long id,
int version,
String title,
String fileName,
String fileUrl,
Long fileSize
Long fileSize,
LocalDate createdDate
) {
public static DocumentVersionResponse of(final DocumentVersion documentVersion, final String fileUrl) {
return DocumentVersionResponse.builder()
Expand All @@ -21,6 +24,7 @@ public static DocumentVersionResponse of(final DocumentVersion documentVersion,
.fileName(documentVersion.getOriginFileName())
.fileUrl(fileUrl)
.fileSize(documentVersion.getFileSize())
.createdDate(documentVersion.getCreatedDate().toLocalDate())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

import static com.jobnote.global.common.ResponseCode.NOT_FOUND_DOCUMENT;

@Service
Expand All @@ -44,6 +46,7 @@ public Long uploadNewDocument(final Long userId, final DocumentRequest request)
public Long uploadNewVersionDocument(final Long userId, final Long documentId, final DocumentRequest request) {
Document document = getByIdOrThrow(documentId);
document.validateOwner(userId);
document.updateModifiedDate(LocalDateTime.now());

int version = documentVersionRepository.findLatestVersionByDocumentId(documentId) + 1;

Expand Down
Loading