Skip to content

Commit

Permalink
feat(#53): converted archive dto v1 classes java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
KimDoubleB committed Jan 18, 2023
1 parent 1bd1cee commit be8d521
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 197 deletions.

This file was deleted.

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

data class ArchiveCountResponseDtoV1(val count: Long)

This file was deleted.

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

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.domain.user.BaseUser
import java.time.LocalDate

@JsonInclude(JsonInclude.Include.NON_NULL)
data class ArchiveDtoV1(
val archiveId: Long,
val name: String,
val watchedOn: String,
val emotion: Emotion,
val mainImage: String,
val authorId: Long,
val isPublic: Boolean? = null,
val coverImageType: CoverImageType? = null,
var companions: List<String>? = null,
var images: List<ArchiveImageDtoV1>? = null
) {

fun toEntity(user: BaseUser): Archive {
val archivePublic = isPublic ?: false
val archiveCoverImageType = coverImageType ?: CoverImageType.EMOTION_COVER
return Archive.builder()
.name(name)
.watchedOn(LocalDate.parse(watchedOn, yymmddFormatter))
.emotion(emotion)
.mainImage(mainImage)
.companions(companions)
.author(user)
.isPublic(archivePublic)
.coverImageType(archiveCoverImageType)
.build()
}

companion object {
/**
* 아카이브 상세 조회 DTO V1
* 아카이브 연결 이미지들을 다 포함
*
* @param archive Archive Entity
* @return ArchiveDtoV1 archive specific DTO
*/
@JvmStatic
fun specificForm(archive: Archive): ArchiveDtoV1 {
val archiveImages = archive.archiveImages.map(ArchiveImageDtoV1::from).toList()
return ArchiveDtoV1(
archiveId = archive.id,
name = archive.name,
watchedOn = archive.watchedOn.format(yymmddFormatter),
emotion = archive.emotion,
mainImage = archive.mainImage,
companions = archive.companions,
images = archiveImages,
authorId = archive.author.id,
isPublic = archive.isPublic
)
}

/**
* 아카이브 리스트 조회 DTO
* 아카이브 연결 이미지들을 포함하고 있지 않음
*
* @param archive archive entity
* @return ArchiveDtoV1 archive simple DTO
*/
@JvmStatic
fun simpleForm(archive: Archive): ArchiveDtoV1 {
return ArchiveDtoV1(
archiveId = archive.id,
name = archive.name,
watchedOn = archive.watchedOn.format(yymmddFormatter),
emotion = archive.emotion,
companions = archive.companions,
mainImage = archive.mainImage,
authorId = archive.author.id,
isPublic = archive.isPublic,
coverImageType = archive.coverImageType
)
}
}

}

This file was deleted.

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

import site.archive.domain.archive.Archive
import site.archive.domain.archive.ArchiveImage

data class ArchiveImageDtoV1(
val archiveImageId: Long,
val image: String,
val review: String,
val backgroundColor: String
) {

fun toEntity(archive: Archive): ArchiveImage {
return ArchiveImage(image, review, backgroundColor, archive)
}

companion object {
@JvmStatic
fun from(archiveImage: ArchiveImage): ArchiveImageDtoV1 {
return ArchiveImageDtoV1(
archiveImageId = archiveImage.id,
image = archiveImage.image,
review = archiveImage.review,
backgroundColor = archiveImage.backgroundColor
)
}
}

}

This file was deleted.

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

data class ArchiveImageUrlResponseDtoV1(val imageUrl: String)

This file was deleted.

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

data class ArchiveListResponseDtoV1(
val archiveCount: Int,
val archives: List<ArchiveDtoV1>
) {

private constructor(archives: List<ArchiveDtoV1>) : this(archives.size, archives)

companion object {
@JvmStatic
fun from(archiveDtoV1s: List<ArchiveDtoV1>): ArchiveListResponseDtoV1 {
return ArchiveListResponseDtoV1(archiveDtoV1s)
}
}

}

This file was deleted.

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

data class EmailDuplicateResponseDtoV1(val isDuplicatedEmail: Boolean)
Loading

0 comments on commit be8d521

Please sign in to comment.