diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarEntity.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarEntity.kt index d5d63b6b..264c13d6 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarEntity.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarEntity.kt @@ -8,6 +8,7 @@ import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEnti import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity import com.wafflestudio.csereal.core.seminar.dto.SeminarDto import jakarta.persistence.* +import java.time.LocalDateTime @Entity(name = "seminar") class SeminarEntity( @@ -35,8 +36,8 @@ class SeminarEntity( var affiliation: String, var affiliationURL: String?, - var startDate: String?, - var endDate: String?, + var startDate: LocalDateTime?, + var endDate: LocalDateTime?, var location: String, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt index 46bb4981..4043fd4b 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt @@ -4,7 +4,6 @@ import com.querydsl.core.BooleanBuilder import com.querydsl.jpa.impl.JPAQueryFactory import com.wafflestudio.csereal.common.CserealException import com.wafflestudio.csereal.common.utils.FixedPageRequest -import com.wafflestudio.csereal.common.utils.cleanTextFromHtml import com.wafflestudio.csereal.core.resource.mainImage.service.MainImageService import com.wafflestudio.csereal.core.seminar.database.QSeminarEntity.seminarEntity import com.wafflestudio.csereal.core.seminar.dto.SeminarSearchDto @@ -75,11 +74,7 @@ class SeminarRepositoryImpl( var isYearLast = false if (i == seminarEntityList.size - 1) { isYearLast = true - } else if (seminarEntityList[i].startDate?.substring(0, 4) != seminarEntityList[i + 1].startDate?.substring( - 0, - 4 - ) - ) { + } else if (seminarEntityList[i].startDate?.year != seminarEntityList[i + 1].startDate?.year) { isYearLast = true } @@ -100,6 +95,6 @@ class SeminarRepositoryImpl( ) } - return SeminarSearchResponse(total!!, seminarSearchDtoList) + return SeminarSearchResponse(total, seminarSearchDtoList) } } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarDto.kt index 91c58b78..2855ec2a 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarDto.kt @@ -15,8 +15,8 @@ data class SeminarDto( val speakerTitle: String?, val affiliation: String, val affiliationURL: String?, - val startDate: String?, - val endDate: String?, + val startDate: LocalDateTime?, + val endDate: LocalDateTime?, val location: String, val host: String?, val additionalNote: String?, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarSearchDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarSearchDto.kt index 483f8513..6bd7c055 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarSearchDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/dto/SeminarSearchDto.kt @@ -1,6 +1,7 @@ package com.wafflestudio.csereal.core.seminar.dto import com.querydsl.core.annotations.QueryProjection +import java.time.LocalDateTime data class SeminarSearchDto @QueryProjection constructor( val id: Long, @@ -8,9 +9,9 @@ data class SeminarSearchDto @QueryProjection constructor( val description: String, val name: String, val affiliation: String, - val startDate: String?, + val startDate: LocalDateTime?, val location: String, val imageURL: String?, val isYearLast: Boolean, ) { -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt b/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt index 0ff9573a..64359c52 100644 --- a/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt +++ b/src/test/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarServiceTest.kt @@ -9,13 +9,14 @@ import io.kotest.matchers.shouldNotBe import jakarta.transaction.Transactional import org.springframework.boot.test.context.SpringBootTest import org.springframework.data.repository.findByIdOrNull +import java.time.LocalDateTime @SpringBootTest @Transactional -class SeminarServiceTest ( +class SeminarServiceTest( private val seminarService: SeminarService, private val seminarRepository: SeminarRepository, -): BehaviorSpec() { +) : BehaviorSpec() { init { beforeContainer { @@ -27,42 +28,42 @@ class SeminarServiceTest ( Given("세미나를 생성하려고 할 때") { val seminarDTO = SeminarDto( - id = -1, - title = "title", - description = """ + id = -1, + title = "title", + description = """

Hello, World!

This is seminar description.

Goodbye, World!

""".trimIndent(), - introduction = """ + introduction = """

Hello, World!

This is seminar introduction.

Goodbye, World!

""".trimIndent(), - name = "name", - speakerURL = "speakerURL", - speakerTitle = "speakerTitle", - affiliation = "affiliation", - affiliationURL = "affiliationURL", - startDate = "startDate", - endDate = "endDate", - location = "location", - host = "host", - additionalNote = """ + name = "name", + speakerURL = "speakerURL", + speakerTitle = "speakerTitle", + affiliation = "affiliation", + affiliationURL = "affiliationURL", + startDate = LocalDateTime.now(), + endDate = LocalDateTime.now(), + location = "location", + host = "host", + additionalNote = """

Hello, World!

This is seminar additionalNote.

Goodbye, World!

""".trimIndent(), - createdAt = null, - modifiedAt = null, - isPrivate = false, - isImportant = false, - prevId = null, - prevTitle = null, - nextId = null, - nextTitle = null, - imageURL = null, - attachments = null + createdAt = null, + modifiedAt = null, + isPrivate = false, + isImportant = false, + prevId = null, + prevTitle = null, + nextId = null, + nextTitle = null, + imageURL = null, + attachments = null ) When("간단한 세미나 DTO가 주어지면") { val resultSeminarDTO = seminarService.createSeminar(seminarDTO, null, null) @@ -83,58 +84,58 @@ class SeminarServiceTest ( Given("기존 간단한 세미나의 Description을 수정하려고 할 때") { val originalSeminar = seminarRepository.save( - SeminarEntity( - title = "title", - description = """ + SeminarEntity( + title = "title", + description = """

Hello, World!

This is seminar description.

Goodbye, World!

""".trimIndent(), - plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!", - introduction = """ + plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!", + introduction = """

Hello, World!

This is seminar introduction.

Goodbye, World!

""".trimIndent(), - plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!", - name = "name", - speakerURL = "speakerURL", - speakerTitle = "speakerTitle", - affiliation = "affiliation", - affiliationURL = "affiliationURL", - startDate = "startDate", - endDate = "endDate", - location = "location", - host = "host", - additionalNote = """ + plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!", + name = "name", + speakerURL = "speakerURL", + speakerTitle = "speakerTitle", + affiliation = "affiliation", + affiliationURL = "affiliationURL", + startDate = LocalDateTime.now(), + endDate = LocalDateTime.now(), + location = "location", + host = "host", + additionalNote = """

Hello, World!

This is seminar additionalNote.

Goodbye, World!

""".trimIndent(), - plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!", - isPrivate = false, - isImportant = false, - ) + plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!", + isPrivate = false, + isImportant = false, + ) ) val originalId = originalSeminar.id When("수정된 DTO를 이용하여 수정하면") { val modifiedSeminarDTO = SeminarDto.of( - originalSeminar, null, emptyList(), null + originalSeminar, null, emptyList(), null ).copy( - description = """ + description = """

Hello, World!

This is modified seminar description.

Goodbye, World!

And this is a new line.

""".trimIndent(), - introduction = """ + introduction = """

Hello, World!

This is modified seminar introduction.

Goodbye, World!

And this is a new line.

""".trimIndent(), - additionalNote = """ + additionalNote = """

Hello, World!

This is modified seminar additionalNote.

Goodbye, World!

@@ -143,11 +144,11 @@ class SeminarServiceTest ( ) val modifiedSeminarDto = seminarService.updateSeminar( - originalSeminar.id, - modifiedSeminarDTO, - null, - null, - emptyList() + originalSeminar.id, + modifiedSeminarDTO, + null, + null, + emptyList() ) Then("같은 Entity가 수정되어야 한다.") { @@ -165,4 +166,4 @@ class SeminarServiceTest ( } } } -} \ No newline at end of file +}