Skip to content

Commit

Permalink
feat(#53): converted dto v2 classes java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
KimDoubleB committed Jan 21, 2023
1 parent 285db7e commit 1888bdf
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 272 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package site.archive.dto.v2

import site.archive.common.yymmddFormatter
import site.archive.domain.archive.Archive
import site.archive.domain.archive.CoverImageType
import site.archive.domain.archive.Emotion

class ArchiveCommunityResponseDto(
val archiveId: Long,
val name: String,
val watchedOn: String,
val emotion: Emotion,
val mainImage: String,
val coverImageType: CoverImageType,
val authorId: Long,
val authorNickname: String,
val authorProfileImage: String,
val isLiked: Boolean,
val likeCount: Long,
val dateMilli: Long
) {
companion object {
@JvmStatic
fun from(archive: Archive, currentUserIdx: Long, dateMilli: Long): ArchiveCommunityResponseDto {
val author = archive.author
val isLiked = archive.likes.stream()
.anyMatch { !it.isDeleted && it.user.id.equals(currentUserIdx) }
val likeCount = archive.likes.stream()
.filter { !it.isDeleted }
.count()
return ArchiveCommunityResponseDto(
archiveId = archive.id,
name = archive.name,
watchedOn = archive.watchedOn.format(yymmddFormatter),
emotion = archive.emotion,
mainImage = archive.mainImage,
coverImageType = archive.coverImageType,
authorId = author.id,
authorNickname = author.nickname,
authorProfileImage = author.profileImage,
isLiked = isLiked,
likeCount = likeCount,
dateMilli = dateMilli
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package site.archive.dto.v2

import com.fasterxml.jackson.annotation.JsonInclude
import site.archive.common.yymmddFormatter
import site.archive.domain.archive.Archive
import site.archive.domain.archive.CoverImageType
import site.archive.domain.archive.Emotion
import site.archive.dto.v1.archive.ArchiveImageDtoV1

@JsonInclude(JsonInclude.Include.NON_NULL)
class ArchiveDtoV2(
val archiveId: Long,
val name: String,
val watchedOn: String,
val emotion: Emotion,
val mainImage: String,
val isPublic: Boolean,
val coverImageType: CoverImageType,
val authorId: Long,
val nickname: String,
val profileImage: String,
val companions: List<String>? = null,
val images: List<ArchiveImageDtoV1>? = null
) {
companion object {
@JvmStatic
fun specificFrom(archive: Archive): ArchiveDtoV2 {
val archiveImages = archive.archiveImages.stream()
.map(ArchiveImageDtoV1::from)
.toList()
val author = archive.author
return ArchiveDtoV2(
archiveId = archive.id,
name = archive.name,
watchedOn = archive.watchedOn.format(yymmddFormatter),
emotion = archive.emotion,
mainImage = archive.mainImage,
companions = archive.companions,
images = archiveImages,
authorId = author.id,
nickname = author.nickname,
profileImage = author.profileImage,
isPublic = archive.isPublic,
coverImageType = archive.coverImageType
)
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package site.archive.dto.v2

class ArchiveLikeListResponseDto(val archiveCount: Int, val archives: List<ArchiveLikeResponseDto>)
Loading

0 comments on commit 1888bdf

Please sign in to comment.