diff --git a/data/src/main/java/com/kongjak/koreatechboard/data/dao/ArticleDao.kt b/data/src/main/java/com/kongjak/koreatechboard/data/dao/ArticleDao.kt index 74acccb8..d89c7c2c 100644 --- a/data/src/main/java/com/kongjak/koreatechboard/data/dao/ArticleDao.kt +++ b/data/src/main/java/com/kongjak/koreatechboard/data/dao/ArticleDao.kt @@ -10,7 +10,7 @@ import java.util.UUID @Dao interface ArticleDao { - @Query("SELECT * FROM article ORDER BY write_date DESC") + @Query("SELECT * FROM article ORDER BY is_notice DESC, write_date DESC, received_time DESC, num DESC") fun getAll(): List
@Query("SELECT * FROM article WHERE uuid = :uuid") diff --git a/data/src/main/java/com/kongjak/koreatechboard/data/enity/Article.kt b/data/src/main/java/com/kongjak/koreatechboard/data/enity/Article.kt index 90ce2062..99a0576d 100644 --- a/data/src/main/java/com/kongjak/koreatechboard/data/enity/Article.kt +++ b/data/src/main/java/com/kongjak/koreatechboard/data/enity/Article.kt @@ -8,6 +8,8 @@ import java.util.UUID @Entity data class Article( @PrimaryKey val uuid: UUID, + @ColumnInfo("num") + val num: Int, @ColumnInfo("title") val title: String, @ColumnInfo("writer") @@ -23,5 +25,9 @@ data class Article( @ColumnInfo("board") val board: String, @ColumnInfo("read") - val read: Boolean + val read: Boolean, + @ColumnInfo("is_notice") + val isNotice: Boolean, + @ColumnInfo("received_time") + val receivedTime: Long ) diff --git a/data/src/main/java/com/kongjak/koreatechboard/data/mapper/DatabaseMapper.kt b/data/src/main/java/com/kongjak/koreatechboard/data/mapper/DatabaseMapper.kt index 048c2033..9b7154ca 100644 --- a/data/src/main/java/com/kongjak/koreatechboard/data/mapper/DatabaseMapper.kt +++ b/data/src/main/java/com/kongjak/koreatechboard/data/mapper/DatabaseMapper.kt @@ -8,6 +8,7 @@ fun List
.mapToLocalArticle(): List { return this.map { LocalArticle( uuid = it.uuid, + num = it.num, title = it.title, writer = it.writer, content = it.content, @@ -15,7 +16,9 @@ fun List
.mapToLocalArticle(): List { articleUrl = it.articleUrl, department = it.department, board = it.board, - read = it.read + read = it.read, + isNotice = it.isNotice, + receivedTime = it.receivedTime ) } } @@ -24,6 +27,7 @@ fun List.mapToArticle(): List
{ return this.map { Article( uuid = it.uuid, + num = it.num, title = it.title, writer = it.writer, content = it.content, @@ -31,7 +35,9 @@ fun List.mapToArticle(): List
{ articleUrl = it.articleUrl, department = it.department, board = it.board, - read = it.read + read = it.read, + isNotice = it.isNotice, + receivedTime = it.receivedTime ) } } @@ -39,6 +45,7 @@ fun List.mapToArticle(): List
{ fun LocalArticle.mapToArticle(): Article { return Article( uuid = this.uuid, + num = this.num, title = this.title, writer = this.writer, content = this.content, @@ -46,13 +53,16 @@ fun LocalArticle.mapToArticle(): Article { articleUrl = this.articleUrl, department = this.department, board = this.board, - read = this.read + read = this.read, + isNotice = this.isNotice, + receivedTime = this.receivedTime ) } fun Article.mapToLocalArticle(): LocalArticle { return LocalArticle( uuid = this.uuid, + num = this.num, title = this.title, writer = this.writer, content = this.content, @@ -60,13 +70,16 @@ fun Article.mapToLocalArticle(): LocalArticle { articleUrl = this.articleUrl, department = this.department, board = this.board, - read = this.read + read = this.read, + isNotice = this.isNotice, + receivedTime = this.receivedTime ) } fun ArticleResponse.mapToArticle(department: String, board: String): Article { return Article( uuid = this.uuid, + num = this.num, title = this.title, writer = this.writer, content = this.content, @@ -74,6 +87,8 @@ fun ArticleResponse.mapToArticle(department: String, board: String): Article { articleUrl = this.articleUrl, department = department, board = board, - read = false + read = false, + isNotice = this.isNotice, + receivedTime = System.currentTimeMillis() ) } diff --git a/data/src/main/java/com/kongjak/koreatechboard/data/model/ArticleResponse.kt b/data/src/main/java/com/kongjak/koreatechboard/data/model/ArticleResponse.kt index f429fcd2..4f944617 100644 --- a/data/src/main/java/com/kongjak/koreatechboard/data/model/ArticleResponse.kt +++ b/data/src/main/java/com/kongjak/koreatechboard/data/model/ArticleResponse.kt @@ -6,6 +6,8 @@ import java.util.UUID data class ArticleResponse( @SerializedName("id") val uuid: UUID, + @SerializedName("num") + val num: Int, @SerializedName("title") val title: String, @SerializedName("writer") @@ -16,6 +18,8 @@ data class ArticleResponse( val date: String, @SerializedName("article_url") val articleUrl: String, + @SerializedName("is_notice") + val isNotice: Boolean, @SerializedName("files") val files: ArrayList ) diff --git a/domain/src/main/java/com/kongjak/koreatechboard/domain/model/LocalArticle.kt b/domain/src/main/java/com/kongjak/koreatechboard/domain/model/LocalArticle.kt index 9707711c..4b2387d7 100644 --- a/domain/src/main/java/com/kongjak/koreatechboard/domain/model/LocalArticle.kt +++ b/domain/src/main/java/com/kongjak/koreatechboard/domain/model/LocalArticle.kt @@ -4,6 +4,7 @@ import java.util.UUID data class LocalArticle( val uuid: UUID, + val num: Int, val title: String, val writer: String, val content: String, @@ -11,5 +12,7 @@ data class LocalArticle( val articleUrl: String, val department: String, val board: String, - val read: Boolean + val read: Boolean, + val isNotice: Boolean, + val receivedTime: Long )