Skip to content

Commit

Permalink
feat: Add is_notice and order by it
Browse files Browse the repository at this point in the history
  • Loading branch information
kongwoojin committed Apr 8, 2024
1 parent 67d3f0f commit beb1661
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Article>

@Query("SELECT * FROM article WHERE uuid = :uuid")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ fun List<Article>.mapToLocalArticle(): List<LocalArticle> {
return this.map {
LocalArticle(
uuid = it.uuid,
num = it.num,
title = it.title,
writer = it.writer,
content = it.content,
date = it.date,
articleUrl = it.articleUrl,
department = it.department,
board = it.board,
read = it.read
read = it.read,
isNotice = it.isNotice,
receivedTime = it.receivedTime
)
}
}
Expand All @@ -24,56 +27,68 @@ fun List<LocalArticle>.mapToArticle(): List<Article> {
return this.map {
Article(
uuid = it.uuid,
num = it.num,
title = it.title,
writer = it.writer,
content = it.content,
date = it.date,
articleUrl = it.articleUrl,
department = it.department,
board = it.board,
read = it.read
read = it.read,
isNotice = it.isNotice,
receivedTime = it.receivedTime
)
}
}

fun LocalArticle.mapToArticle(): Article {
return Article(
uuid = this.uuid,
num = this.num,
title = this.title,
writer = this.writer,
content = this.content,
date = this.date,
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,
date = this.date,
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,
date = this.date,
articleUrl = this.articleUrl,
department = department,
board = board,
read = false
read = false,
isNotice = this.isNotice,
receivedTime = System.currentTimeMillis()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<FilesResponse>
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import java.util.UUID

data class LocalArticle(
val uuid: UUID,
val num: Int,
val title: String,
val writer: String,
val content: String,
val date: String,
val articleUrl: String,
val department: String,
val board: String,
val read: Boolean
val read: Boolean,
val isNotice: Boolean,
val receivedTime: Long
)

0 comments on commit beb1661

Please sign in to comment.