diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsEntity.kt b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsEntity.kt index 216fc5e2..73ab66b2 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsEntity.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsEntity.kt @@ -25,7 +25,7 @@ class NewsEntity( @Column(columnDefinition = "mediumtext") var plainTextDescription: String, - var date: LocalDateTime?, + var date: LocalDateTime, var isPrivate: Boolean, var isSlide: Boolean, var isImportant: Boolean, diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt index 80aad842..f545201c 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt @@ -102,7 +102,7 @@ class NewsRepositoryImpl( } val newsEntityList = jpaQuery - .orderBy(newsEntity.createdAt.desc()) + .orderBy(newsEntity.date.desc()) .offset(pageRequest.offset) .limit(pageRequest.pageSize.toLong()) .distinct() diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/news/dto/NewsDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/news/dto/NewsDto.kt index e78020fd..c913d702 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/news/dto/NewsDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/news/dto/NewsDto.kt @@ -12,7 +12,7 @@ data class NewsDto( val tags: List, val createdAt: LocalDateTime?, val modifiedAt: LocalDateTime?, - val date: LocalDateTime?, + val date: LocalDateTime, val isPrivate: Boolean, val isSlide: Boolean, val isImportant: Boolean, diff --git a/src/test/kotlin/com/wafflestudio/csereal/core/notice/news/NewsServiceTest.kt b/src/test/kotlin/com/wafflestudio/csereal/core/news/NewsServiceTest.kt similarity index 93% rename from src/test/kotlin/com/wafflestudio/csereal/core/notice/news/NewsServiceTest.kt rename to src/test/kotlin/com/wafflestudio/csereal/core/news/NewsServiceTest.kt index 13c9f8c7..a6ea95d7 100644 --- a/src/test/kotlin/com/wafflestudio/csereal/core/notice/news/NewsServiceTest.kt +++ b/src/test/kotlin/com/wafflestudio/csereal/core/news/NewsServiceTest.kt @@ -1,4 +1,4 @@ -package com.wafflestudio.csereal.core.notice.news +package com.wafflestudio.csereal.core.news import com.wafflestudio.csereal.core.news.database.NewsEntity import com.wafflestudio.csereal.core.news.database.NewsRepository @@ -9,6 +9,7 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import org.springframework.boot.test.context.SpringBootTest import org.springframework.data.repository.findByIdOrNull +import java.time.LocalDateTime @SpringBootTest class NewsServiceTest( @@ -34,7 +35,7 @@ class NewsServiceTest( tags = emptyList(), createdAt = null, modifiedAt = null, - date = null, + date = LocalDateTime.now(), isPrivate = false, isSlide = false, isImportant = false, @@ -72,7 +73,7 @@ class NewsServiceTest(

Goodbye, World!

""".trimIndent(), plainTextDescription = "Hello, World! This is news description. Goodbye, World!", - date = null, + date = LocalDateTime.now(), isPrivate = false, isSlide = false, isImportant = false, @@ -103,7 +104,8 @@ class NewsServiceTest(

Goodbye, World!

This is additional description.

""".trimIndent() - updatedNewsEntity.plainTextDescription shouldBe "Hello, World! This is modified news description. Goodbye, World! This is additional description." + updatedNewsEntity.plainTextDescription shouldBe "Hello, World! This is modified news description." + + " Goodbye, World! This is additional description." } } }