parent
81f3972b55
commit
6235e5ca60
@ -1,18 +0,0 @@
|
|||||||
package wanijo.wanijo2.domain
|
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id
|
|
||||||
import org.springframework.data.relational.core.mapping.Table
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
|
|
||||||
@Table("T_DOCUMENT")
|
|
||||||
data class Document(
|
|
||||||
@Id
|
|
||||||
val id: Long = 0,
|
|
||||||
val name: String,
|
|
||||||
val description: String = "",
|
|
||||||
val updatedAt: ZonedDateTime = ZonedDateTime.now(),
|
|
||||||
val createdAt: ZonedDateTime = ZonedDateTime.now(),
|
|
||||||
val labelFields: Set<LabelField> = emptySet(),
|
|
||||||
val dateFields: Set<DateField> = emptySet(),
|
|
||||||
val tags: Set<Tag> = emptySet()
|
|
||||||
)
|
|
@ -1,27 +0,0 @@
|
|||||||
package wanijo.wanijo2.domain
|
|
||||||
|
|
||||||
import org.springframework.data.jdbc.repository.query.Query
|
|
||||||
import org.springframework.data.repository.Repository
|
|
||||||
|
|
||||||
interface DocumentDao: Repository<Document, Int> {
|
|
||||||
|
|
||||||
fun findAll(): List<Document>
|
|
||||||
|
|
||||||
fun findById(id: Long): Document?
|
|
||||||
|
|
||||||
fun findByName(name: String): List<Document>
|
|
||||||
|
|
||||||
fun save(doc: Document)
|
|
||||||
|
|
||||||
@Query(
|
|
||||||
"""
|
|
||||||
SELECT doc.*
|
|
||||||
FROM t_document doc
|
|
||||||
JOIN t_tag tag
|
|
||||||
ON doc.id = tag.t_document
|
|
||||||
WHERE LOWER(tag.name) LIKE '%' || LOWER(:tagName) || '%'
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
fun findByTagName(tagName: String): List<Document>
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package wanijo.wanijo2.domain
|
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id
|
|
||||||
import org.springframework.data.relational.core.mapping.Table
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
|
|
||||||
@Table("T_TAG")
|
|
||||||
data class Tag(
|
|
||||||
@Id
|
|
||||||
val id: Long = 0,
|
|
||||||
val name: String,
|
|
||||||
val createdAt: ZonedDateTime = ZonedDateTime.now()
|
|
||||||
)
|
|
@ -0,0 +1,45 @@
|
|||||||
|
package wanijo.wanijo2.domain
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id
|
||||||
|
import org.springframework.data.annotation.Transient
|
||||||
|
import org.springframework.data.jdbc.repository.query.Query
|
||||||
|
import org.springframework.data.relational.core.mapping.Table
|
||||||
|
import org.springframework.data.repository.Repository
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
@Table("T_DOCUMENT")
|
||||||
|
data class Document(
|
||||||
|
@Id
|
||||||
|
val id: Long = 0,
|
||||||
|
val name: String,
|
||||||
|
val description: String = "",
|
||||||
|
val updatedAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
val createdAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
val labelFields: Set<LabelField> = emptySet(),
|
||||||
|
val dateFields: Set<DateField> = emptySet(),
|
||||||
|
) {
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
val tags: Set<Tag> = emptySet()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DocumentDao: Repository<Document, Int> {
|
||||||
|
fun findAll(): List<Document>
|
||||||
|
fun findById(id: Long): Document?
|
||||||
|
fun findByName(name: String): List<Document>
|
||||||
|
fun save(doc: Document): Document
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
SELECT doc.*
|
||||||
|
FROM t_document doc
|
||||||
|
JOIN t_document_tagging tagging
|
||||||
|
ON tagging.document_id = doc.id
|
||||||
|
JOIN t_tag tag
|
||||||
|
ON tagging.tag_id = tag.id
|
||||||
|
WHERE LOWER(tag.name) LIKE '%' || LOWER(:tagName) || '%'
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
fun findByTagName(tagName: String): List<Document>
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package wanijo.wanijo2.domain
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id
|
||||||
|
import org.springframework.data.jdbc.core.mapping.AggregateReference
|
||||||
|
import org.springframework.data.relational.core.mapping.Table
|
||||||
|
import org.springframework.data.repository.Repository
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
@Table("T_TAG")
|
||||||
|
data class Tag(
|
||||||
|
@Id
|
||||||
|
val id: Long = 0,
|
||||||
|
val name: String,
|
||||||
|
val createdAt: ZonedDateTime = ZonedDateTime.now()
|
||||||
|
)
|
||||||
|
|
||||||
|
@Table("T_DOCUMENT_TAGGING")
|
||||||
|
data class DocumentTagging(
|
||||||
|
@Id
|
||||||
|
val id: Long = 0,
|
||||||
|
val tagId: AggregateReference<Tag, Long>,
|
||||||
|
val documentId: AggregateReference<Document, Long>
|
||||||
|
)
|
||||||
|
|
||||||
|
interface DocumentTaggingDao : Repository<DocumentTagging, Long> {
|
||||||
|
fun save(tagging: DocumentTagging)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TagDao: Repository<Tag, Long> {
|
||||||
|
fun save(tag: Tag): Tag
|
||||||
|
fun findByName(name: String): Tag?
|
||||||
|
}
|
Loading…
Reference in new issue