mirror of
https://github.com/vran-dev/databasir.git
synced 2025-10-29 11:29:19 +08:00
Feature: support custom document table header (#60)
* feat: template property jooq generate * feat: add template property api * feat: update export logic * feat: update frontend resources
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.databasir.dao.converter;
|
||||
|
||||
import com.databasir.dao.enums.DocumentTemplatePropertyType;
|
||||
import org.jooq.impl.EnumConverter;
|
||||
|
||||
public class DocumentTemplatePropertyTypeConverter extends EnumConverter<String, DocumentTemplatePropertyType> {
|
||||
|
||||
public DocumentTemplatePropertyTypeConverter() {
|
||||
super(String.class, DocumentTemplatePropertyType.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.databasir.dao.enums;
|
||||
|
||||
public enum DocumentTemplatePropertyType {
|
||||
|
||||
INDEX_FIELD_NAME, COLUMN_FIELD_NAME, TRIGGER_FIELD_NAME, FOREIGN_KEY_FIELD_NAME;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.databasir.dao.impl;
|
||||
|
||||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo;
|
||||
import com.databasir.dao.tables.records.DocumentTemplatePropertyRecord;
|
||||
import lombok.Getter;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.InsertReturningStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.databasir.dao.Tables.DOCUMENT_TEMPLATE_PROPERTY;
|
||||
|
||||
@Repository
|
||||
public class DocumentTemplatePropertyDao extends BaseDao<DocumentTemplatePropertyPojo> {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
private DSLContext dslContext;
|
||||
|
||||
public DocumentTemplatePropertyDao() {
|
||||
super(DOCUMENT_TEMPLATE_PROPERTY, DocumentTemplatePropertyPojo.class);
|
||||
}
|
||||
|
||||
public void batchInsertOnDuplicateIgnore(Collection<DocumentTemplatePropertyPojo> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<InsertReturningStep<DocumentTemplatePropertyRecord>> query = data.stream()
|
||||
.map(pojo ->
|
||||
|
||||
getDslContext()
|
||||
.insertInto(DOCUMENT_TEMPLATE_PROPERTY)
|
||||
.set(getDslContext().newRecord(DOCUMENT_TEMPLATE_PROPERTY, pojo))
|
||||
.onDuplicateKeyIgnore())
|
||||
.collect(Collectors.toList());
|
||||
getDslContext().batch(query).execute();
|
||||
}
|
||||
|
||||
public void batchInsertOnDuplicateKeyUpdate(Collection<DocumentTemplatePropertyPojo> data) {
|
||||
if (data == null || data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<InsertReturningStep<DocumentTemplatePropertyRecord>> query = data.stream()
|
||||
.map(pojo -> getDslContext()
|
||||
.insertInto(DOCUMENT_TEMPLATE_PROPERTY)
|
||||
.set(getDslContext().newRecord(DOCUMENT_TEMPLATE_PROPERTY, pojo))
|
||||
.onDuplicateKeyUpdate()
|
||||
.set(DOCUMENT_TEMPLATE_PROPERTY.VALUE, pojo.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
getDslContext().batch(query).execute();
|
||||
}
|
||||
}
|
||||
@@ -330,4 +330,16 @@ CREATE TABLE IF NOT EXISTS document_description
|
||||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UNIQUE uk_project_id_table_name_column_name (project_id, table_name, column_name)
|
||||
) CHARSET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci COMMENT 'custom document description';
|
||||
COLLATE utf8mb4_unicode_ci COMMENT 'custom document description';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS document_template_property
|
||||
(
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`key` VARCHAR(255) NOT NULL,
|
||||
`value` VARCHAR(255) DEFAULT NULL,
|
||||
`default_value` VARCHAR(255) NOT NULL,
|
||||
`type` VARCHAR(64) NOT NULL,
|
||||
`create_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT UNIQUE uk_type_key (`type`, `key`)
|
||||
) CHARSET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci COMMENT 'template property';
|
||||
Reference in New Issue
Block a user