parent
dfeb045f1a
commit
81f3972b55
@ -1,15 +1,27 @@
|
|||||||
package wanijo.wanijo2.domain
|
package wanijo.wanijo2.domain
|
||||||
|
|
||||||
|
import org.springframework.data.jdbc.repository.query.Query
|
||||||
import org.springframework.data.repository.Repository
|
import org.springframework.data.repository.Repository
|
||||||
|
|
||||||
interface DocumentDao: Repository<Document, Int> {
|
interface DocumentDao: Repository<Document, Int> {
|
||||||
|
|
||||||
fun findAll(): List<Document>
|
fun findAll(): List<Document>
|
||||||
|
|
||||||
fun findById(id: Int): Document?
|
fun findById(id: Long): Document?
|
||||||
|
|
||||||
fun findByName(name: String): List<Document>
|
fun findByName(name: String): List<Document>
|
||||||
|
|
||||||
fun save(doc: 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>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
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,27 @@
|
|||||||
|
package wanijo.wanijo2.domain
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id
|
||||||
|
import org.springframework.data.relational.core.mapping.Table
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
@Table("T_LABEL_FIELD")
|
||||||
|
data class LabelField(
|
||||||
|
@Id
|
||||||
|
val id: Long,
|
||||||
|
val order: Int = 0,
|
||||||
|
val name: String,
|
||||||
|
val value: String = "",
|
||||||
|
val updatedAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
val createdAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
)
|
||||||
|
|
||||||
|
@Table("T_DATE_FIELD")
|
||||||
|
data class DateField(
|
||||||
|
@Id
|
||||||
|
val id: Long,
|
||||||
|
val order: Int = 0,
|
||||||
|
val name: String,
|
||||||
|
val value: ZonedDateTime,
|
||||||
|
val updatedAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
val createdAt: ZonedDateTime = ZonedDateTime.now(),
|
||||||
|
)
|
@ -1,8 +1,9 @@
|
|||||||
CREATE TABLE t_document
|
CREATE TABLE t_document
|
||||||
(
|
(
|
||||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
name VARCHAR NOT NULL,
|
name VARCHAR NOT NULL,
|
||||||
description VARCHAR
|
description VARCHAR
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
CREATE TABLE t_label_field
|
||||||
|
(
|
||||||
|
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||||
|
name VARCHAR NOT NULL,
|
||||||
|
"ORDER" INT NOT NULL DEFAULT 0,
|
||||||
|
"VALUE" VARCHAR,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
t_document INT REFERENCES t_document (id) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE t_date_field
|
||||||
|
(
|
||||||
|
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||||
|
name VARCHAR NOT NULL,
|
||||||
|
"ORDER" INT NOT NULL DEFAULT 0,
|
||||||
|
"VALUE" TIMESTAMP WITH TIME ZONE,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
t_document INT REFERENCES t_document (id) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE t_tag
|
||||||
|
(
|
||||||
|
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||||
|
name VARCHAR NOT NULL,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
||||||
|
t_document INT REFERENCES t_document (id) NOT NULL
|
||||||
|
);
|
Loading…
Reference in new issue