Skip to content

Commit

Permalink
refactor(thumbsup): VersionDocs dto의 class를 record로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
마현우 committed Apr 10, 2024
1 parent 9209155 commit 0e7e2b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CustomDocsRepositoryImpl implements CustomDocsRepository {
public VersionResponseDto getDocsVersion(Docs findDocs) {
List<VersionDocsResponseDto> versionDocsResponseDto = jpaQueryFactory
.select(constructor(VersionDocsResponseDto.class, versionDocs.createdAt, user.id,
user.nickName))
user.nickName, versionDocs.version))
.from(docs)
.join(docs.versionDocs, versionDocs)
.join(versionDocs.user, user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,10 @@

import java.time.LocalDateTime;

import lombok.Getter;

@Getter
public final class VersionDocsResponseDto {
private final LocalDateTime thisVersionCreatedAt;
private final Long userId;
private final String nickName;
private int index;

public VersionDocsResponseDto(LocalDateTime thisVersionCreatedAt, Long userId, String nickName) {
this.thisVersionCreatedAt = thisVersionCreatedAt;
this.userId = userId;
this.nickName = nickName;
}

public void updateIndex(int index) {
this.index = index;
}

public record VersionDocsResponseDto(
LocalDateTime thisVersionCreatedAt,
Long userId,
String nickName,
int index
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@
import com.project.bumawiki.domain.docs.domain.Docs;
import com.project.bumawiki.domain.docs.domain.type.DocsType;

import lombok.Getter;

@Getter
public class VersionResponseDto {
private final int length;
private final List<VersionDocsResponseDto> versionDocsResponseDto;
private final DocsType docsType;
private final String title;
public record VersionResponseDto(
int length,
List<VersionDocsResponseDto> versionDocsResponseDto,
DocsType docsType,
String title
) {

public VersionResponseDto(List<VersionDocsResponseDto> versionDocsResponseDto, Docs findDocs) {
length = versionDocsResponseDto.size();
this.versionDocsResponseDto = versionDocsResponseDto;
this.docsType = findDocs.getDocsType();
this.title = findDocs.getTitle();

int index = length;
for (VersionDocsResponseDto docsResponseDto : versionDocsResponseDto) {
docsResponseDto.updateIndex(index);
index -= 1;
}
this(
versionDocsResponseDto.size(),
versionDocsResponseDto,
findDocs.getDocsType(),
findDocs.getTitle()
);
}
}

0 comments on commit 0e7e2b9

Please sign in to comment.