|
|
|
@ -6,6 +6,8 @@ import org.springframework.data.jdbc.repository.query.Modifying
|
|
|
|
import org.springframework.data.jdbc.repository.query.Query
|
|
|
|
import org.springframework.data.jdbc.repository.query.Query
|
|
|
|
import org.springframework.data.relational.core.mapping.Table
|
|
|
|
import org.springframework.data.relational.core.mapping.Table
|
|
|
|
import org.springframework.data.repository.Repository
|
|
|
|
import org.springframework.data.repository.Repository
|
|
|
|
|
|
|
|
import java.time.LocalDateTime
|
|
|
|
|
|
|
|
import java.time.LocalDateTime.now
|
|
|
|
import java.time.ZonedDateTime
|
|
|
|
import java.time.ZonedDateTime
|
|
|
|
|
|
|
|
|
|
|
|
typealias DocumentId = Long
|
|
|
|
typealias DocumentId = Long
|
|
|
|
@ -18,25 +20,40 @@ data class Document(
|
|
|
|
val id: DocumentId = 0,
|
|
|
|
val id: DocumentId = 0,
|
|
|
|
val name: DocumentName,
|
|
|
|
val name: DocumentName,
|
|
|
|
val description: DocumentDescription = "",
|
|
|
|
val description: DocumentDescription = "",
|
|
|
|
val updatedAt: ZonedDateTime = ZonedDateTime.now(),
|
|
|
|
val updatedAt: LocalDateTime = now(),
|
|
|
|
val createdAt: ZonedDateTime = ZonedDateTime.now(),
|
|
|
|
val createdAt: LocalDateTime = now(),
|
|
|
|
val labelFields: Set<LabelField> = emptySet(),
|
|
|
|
val labelFields: Set<LabelField> = emptySet(),
|
|
|
|
val dateFields: Set<DateField> = emptySet(),
|
|
|
|
val dateFields: Set<DateField> = emptySet(),
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
fun labelFieldsSorted() =
|
|
|
|
fun labelFieldsSorted() =
|
|
|
|
labelFields.sortedBy { it.order }
|
|
|
|
labelFields.sortedBy { it.order }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun dateFieldsSorted() =
|
|
|
|
|
|
|
|
dateFields.sortedBy { it.order }
|
|
|
|
|
|
|
|
|
|
|
|
fun withLabel(field: LabelField) =
|
|
|
|
fun withLabel(field: LabelField) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
labelFields = labelFields + field,
|
|
|
|
labelFields = labelFields + field,
|
|
|
|
updatedAt = ZonedDateTime.now()
|
|
|
|
updatedAt = now()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun withDate(field: DateField) =
|
|
|
|
|
|
|
|
copy(
|
|
|
|
|
|
|
|
dateFields = dateFields + field,
|
|
|
|
|
|
|
|
updatedAt = now()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun withoutLabel(fieldId: FieldId) =
|
|
|
|
fun withoutLabel(fieldId: FieldId) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
updatedAt = ZonedDateTime.now(),
|
|
|
|
updatedAt = now(),
|
|
|
|
labelFields = labelFields.filter { it.id != fieldId }.toSet()
|
|
|
|
labelFields = labelFields.filter { it.id != fieldId }.toSet()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun withoutDate(fieldId: FieldId) =
|
|
|
|
|
|
|
|
copy(
|
|
|
|
|
|
|
|
updatedAt = now(),
|
|
|
|
|
|
|
|
dateFields = dateFields.filter { it.id != fieldId }.toSet()
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Table("T_DOCUMENT")
|
|
|
|
@Table("T_DOCUMENT")
|
|
|
|
|