-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#53): converted dto v2 classes java to kotlin
- Loading branch information
1 parent
285db7e
commit 1888bdf
Showing
14 changed files
with
201 additions
and
272 deletions.
There are no files selected for viewing
53 changes: 0 additions & 53 deletions
53
archive-application/src/main/java/site/archive/dto/v2/ArchiveCommunityResponseDto.java
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
archive-application/src/main/java/site/archive/dto/v2/ArchiveDtoV2.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
archive-application/src/main/java/site/archive/dto/v2/ArchiveLikeListResponseDto.java
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
archive-application/src/main/java/site/archive/dto/v2/ArchiveLikeResponseDto.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
archive-application/src/main/java/site/archive/dto/v2/LikesRequestDto.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
archive-application/src/main/java/site/archive/dto/v2/MyArchiveListResponseDto.java
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
archive-application/src/main/java/site/archive/dto/v2/MyArchiveResponseDto.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
archive-application/src/main/kotlin/site/archive/dto/v2/ArchiveCommunityResponseDto.kt
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 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 | ||
) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
archive-application/src/main/kotlin/site/archive/dto/v2/ArchiveDtoV2.kt
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,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 | ||
) | ||
} | ||
|
||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
archive-application/src/main/kotlin/site/archive/dto/v2/ArchiveLikeListResponseDto.kt
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,3 @@ | ||
package site.archive.dto.v2 | ||
|
||
class ArchiveLikeListResponseDto(val archiveCount: Int, val archives: List<ArchiveLikeResponseDto>) |
Oops, something went wrong.