refactor: change book number from float to int

This commit is contained in:
Gauthier Roebroeck 2020-03-06 17:55:45 +08:00
parent f6fcb97446
commit 02700df0d9
4 changed files with 6 additions and 4 deletions

View file

@ -54,8 +54,8 @@ class Book(
@JoinColumn(name = "media_id", nullable = false)
var media: Media = Media()
@Column(name = "number", nullable = false, columnDefinition = "REAL")
var number: Float = 0F
@Column(name = "number", nullable = false)
var number: Int = 0
fun fileName(): String = FilenameUtils.getName(url.toString())

View file

@ -61,7 +61,7 @@ class Series(
_books.clear()
value.forEach { it.series = this }
_books.addAll(value.sortedWith(compareBy(natSortComparator) { it.name }))
_books.forEachIndexed { index, book -> book.number = index + 1F }
_books.forEachIndexed { index, book -> book.number = index + 1 }
}
@OneToOne(optional = false, orphanRemoval = true, cascade = [CascadeType.ALL], fetch = FetchType.LAZY)

View file

@ -10,7 +10,7 @@ data class BookDto(
val seriesId: Long,
val name: String,
val url: String,
val number: Float,
val number: Int,
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
val created: LocalDateTime?,
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")

View file

@ -0,0 +1,2 @@
alter table book
alter column number set data type int;