|
|
|
@ -6,8 +6,7 @@ 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.Instant
|
|
|
|
import java.time.LocalDateTime.now
|
|
|
|
|
|
|
|
import java.time.ZonedDateTime
|
|
|
|
import java.time.ZonedDateTime
|
|
|
|
|
|
|
|
|
|
|
|
typealias DocumentId = Long
|
|
|
|
typealias DocumentId = Long
|
|
|
|
@ -20,8 +19,8 @@ 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: LocalDateTime = now(),
|
|
|
|
val updatedAt: Instant = Instant.now(),
|
|
|
|
val createdAt: LocalDateTime = now(),
|
|
|
|
val createdAt: Instant = Instant.now(),
|
|
|
|
val labelFields: Set<LabelField> = emptySet(),
|
|
|
|
val labelFields: Set<LabelField> = emptySet(),
|
|
|
|
val dateFields: Set<DateField> = emptySet(),
|
|
|
|
val dateFields: Set<DateField> = emptySet(),
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
@ -33,25 +32,25 @@ data class Document(
|
|
|
|
|
|
|
|
|
|
|
|
fun withLabel(field: LabelField) =
|
|
|
|
fun withLabel(field: LabelField) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
labelFields = labelFields + field,
|
|
|
|
updatedAt = Instant.now(),
|
|
|
|
updatedAt = now()
|
|
|
|
labelFields = labelFields + field
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun withDate(field: DateField) =
|
|
|
|
fun withDate(field: DateField) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
dateFields = dateFields + field,
|
|
|
|
updatedAt = Instant.now(),
|
|
|
|
updatedAt = now()
|
|
|
|
dateFields = dateFields + field
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun withoutLabel(fieldId: FieldId) =
|
|
|
|
fun withoutLabel(fieldId: FieldId) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
updatedAt = now(),
|
|
|
|
updatedAt = Instant.now(),
|
|
|
|
labelFields = labelFields.filter { it.id != fieldId }.toSet()
|
|
|
|
labelFields = labelFields.filter { it.id != fieldId }.toSet()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun withoutDate(fieldId: FieldId) =
|
|
|
|
fun withoutDate(fieldId: FieldId) =
|
|
|
|
copy(
|
|
|
|
copy(
|
|
|
|
updatedAt = now(),
|
|
|
|
updatedAt = Instant.now(),
|
|
|
|
dateFields = dateFields.filter { it.id != fieldId }.toSet()
|
|
|
|
dateFields = dateFields.filter { it.id != fieldId }.toSet()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -61,7 +60,7 @@ data class DocumentBrief(
|
|
|
|
@Id
|
|
|
|
@Id
|
|
|
|
val id: DocumentId,
|
|
|
|
val id: DocumentId,
|
|
|
|
val name: DocumentName,
|
|
|
|
val name: DocumentName,
|
|
|
|
val updatedAt: ZonedDateTime
|
|
|
|
val updatedAt: Instant
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
interface DocumentDao : Repository<Document, DocumentId> {
|
|
|
|
interface DocumentDao : Repository<Document, DocumentId> {
|
|
|
|
|