Skip to content

Commit

Permalink
refactor: modify album entity
Browse files Browse the repository at this point in the history
add isUncategorized field
  • Loading branch information
ShiinaKin committed Sep 17, 2024
1 parent 654b24d commit 229441d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AlbumDaoImpl : AlbumDao {
it[Albums.name],
it[Albums.description],
it[Albums.imageCount],
it[Albums.isUncategorized],
it[Albums.createTime],
)
}
Expand All @@ -35,6 +36,7 @@ class AlbumDaoImpl : AlbumDao {
it[Albums.name],
it[Albums.description],
it[Albums.imageCount],
it[Albums.isUncategorized],
it[Albums.createTime],
)
}
Expand All @@ -47,6 +49,7 @@ class AlbumDaoImpl : AlbumDao {
it[name] = insertDTO.name
it[description] = insertDTO.description
it[imageCount] = insertDTO.imageCount
it[isUncategorized] = insertDTO.isUncategorized
it[createTime] = insertDTO.createTime
}
return entityID.value
Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/io/sakurasou/model/dao/album/Albums.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object Albums : LongIdTable("ablums") {
val name = varchar("name", 255)
val description = varchar("description", 255).nullable()
val imageCount = integer("image_count").check { it greaterEq 0 }
val isUncategorized = bool("is_uncategorized")
val createTime = datetime("create_time")

init {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/kotlin/io/sakurasou/model/dto/AlbumDTO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ data class AlbumInsertDTO(
val name: String,
val description: String? = null,
val imageCount: Int,
val isUncategorized: Boolean,
val createTime: LocalDateTime
)
1 change: 1 addition & 0 deletions app/src/main/kotlin/io/sakurasou/model/entity/Album.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ data class Album(
val name: String,
val description: String? = null,
val imageCount: Int,
val isUncategorized: Boolean,
val createTime: LocalDateTime
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ class AlbumServiceImpl(
) : AlbumService {
override suspend fun initAlbumForUser(userId: Long): Long {
val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
val uncategorizedAlbum = AlbumInsertDTO(userId, "uncategorized", "default, cannot delete", 0, now)
val uncategorizedAlbum = AlbumInsertDTO(
userId = userId,
name = "uncategorized",
description = "default, cannot delete",
imageCount = 0,
isUncategorized = true,
createTime = now
)
return dbQuery {
albumDao.saveAlbum(uncategorizedAlbum)
}
Expand Down

0 comments on commit 229441d

Please sign in to comment.