feat:support generate mock sql
This commit is contained in:
parent
30765be4d4
commit
ff1a186134
|
@ -2,10 +2,7 @@ package com.databasir.api;
|
||||||
|
|
||||||
import com.databasir.common.JsonData;
|
import com.databasir.common.JsonData;
|
||||||
import com.databasir.core.diff.data.RootDiff;
|
import com.databasir.core.diff.data.RootDiff;
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentResponse;
|
import com.databasir.core.domain.document.data.*;
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentSimpleResponse;
|
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse;
|
|
||||||
import com.databasir.core.domain.document.data.TableDocumentResponse;
|
|
||||||
import com.databasir.core.domain.document.generator.DocumentFileType;
|
import com.databasir.core.domain.document.generator.DocumentFileType;
|
||||||
import com.databasir.core.domain.document.service.DocumentService;
|
import com.databasir.core.domain.document.service.DocumentService;
|
||||||
import com.databasir.core.domain.log.annotation.Operation;
|
import com.databasir.core.domain.log.annotation.Operation;
|
||||||
|
@ -94,4 +91,9 @@ public class DocumentController {
|
||||||
return JsonData.ok(documentService.getTableDetails(projectId, documentId, tableIds));
|
return JsonData.ok(documentService.getTableDetails(projectId, documentId, tableIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(Routes.Document.LIST_TABLES)
|
||||||
|
public JsonData<List<TableResponse>> listTables(@PathVariable Integer projectId,
|
||||||
|
@RequestParam(required = false) Long version) {
|
||||||
|
return JsonData.ok(documentService.getTableAndColumns(projectId, version));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.databasir.api;
|
||||||
|
|
||||||
|
import com.databasir.common.JsonData;
|
||||||
|
import com.databasir.core.domain.mock.MockDataService;
|
||||||
|
import com.databasir.core.domain.mock.data.ColumnMockRuleSaveRequest;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataGenerateCondition;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataRuleListCondition;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataRuleResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Validated
|
||||||
|
public class MockDataController {
|
||||||
|
|
||||||
|
private final MockDataService mockDataService;
|
||||||
|
|
||||||
|
@GetMapping(Routes.MockData.GET_SQL_MOCK_DATA)
|
||||||
|
public JsonData<String> getMockSql(@PathVariable("groupId") Integer groupId,
|
||||||
|
@PathVariable("projectId") Integer projectId,
|
||||||
|
@Valid MockDataGenerateCondition condition) {
|
||||||
|
String sql = mockDataService.generateMockInsertSql(projectId, condition);
|
||||||
|
return JsonData.ok(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(Routes.MockData.GET_MOCK_RULE)
|
||||||
|
public JsonData<List<MockDataRuleResponse>> getMockRules(@PathVariable("groupId") Integer groupId,
|
||||||
|
@PathVariable("projectId") Integer projectId,
|
||||||
|
@Valid MockDataRuleListCondition condition) {
|
||||||
|
List<MockDataRuleResponse> rules = mockDataService.listRules(projectId, condition);
|
||||||
|
return JsonData.ok(rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(Routes.MockData.SAVE_MOCK_RULE)
|
||||||
|
@PreAuthorize("hasAnyAuthority('SYS_OWNER', 'GROUP_OWNER?groupId='+#groupId, 'GROUP_MEMBER?groupId='+#groupId)")
|
||||||
|
public JsonData<Void> saveMockRules(@PathVariable Integer groupId,
|
||||||
|
@PathVariable Integer projectId,
|
||||||
|
@PathVariable Integer tableId,
|
||||||
|
@RequestBody @Valid List<ColumnMockRuleSaveRequest> rules) {
|
||||||
|
mockDataService.saveMockRules(projectId, tableId, rules);
|
||||||
|
return JsonData.ok();
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,6 +85,8 @@ public interface Routes {
|
||||||
String DIFF = BASE + "/projects/{projectId}/diff_documents";
|
String DIFF = BASE + "/projects/{projectId}/diff_documents";
|
||||||
|
|
||||||
String EXPORT = BASE + "/projects/{projectId}/document_files";
|
String EXPORT = BASE + "/projects/{projectId}/document_files";
|
||||||
|
|
||||||
|
String LIST_TABLES = BASE + "/projects/{projectId}/tables";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DocumentDiscussion {
|
interface DocumentDiscussion {
|
||||||
|
@ -160,4 +162,14 @@ public interface Routes {
|
||||||
|
|
||||||
String CREATE = BASE + "/database_types";
|
String CREATE = BASE + "/database_types";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MockData {
|
||||||
|
|
||||||
|
String SAVE_MOCK_RULE = BASE + "/groups/{groupId}/projects/{projectId}/tables/{tableId}/mock_rules";
|
||||||
|
|
||||||
|
String GET_MOCK_RULE = BASE + "/groups/{groupId}/projects/{projectId}/mock_rules";
|
||||||
|
|
||||||
|
String GET_SQL_MOCK_DATA = BASE + "/groups/{groupId}/projects/{projectId}/mock_data/sql";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||||
id 'org.springframework.boot' version '2.5.8' apply false
|
id 'org.springframework.boot' version '2.5.11' apply false
|
||||||
id 'nu.studer.jooq' version '6.0.1' apply false
|
id 'nu.studer.jooq' version '6.0.1' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ dependencies {
|
||||||
// others
|
// others
|
||||||
implementation 'com.auth0:java-jwt:3.18.3'
|
implementation 'com.auth0:java-jwt:3.18.3'
|
||||||
implementation 'org.commonmark:commonmark:0.18.1'
|
implementation 'org.commonmark:commonmark:0.18.1'
|
||||||
|
implementation 'com.github.javafaker:javafaker:1.0.2'
|
||||||
implementation 'com.alibaba:easyexcel'
|
implementation 'com.alibaba:easyexcel'
|
||||||
implementation "org.freemarker:freemarker"
|
implementation "org.freemarker:freemarker"
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,14 @@ public enum DomainErrors implements DatabasirErrors {
|
||||||
INVALID_DATABASE_TYPE_URL_PATTERN("A_10019", "不合法的 url pattern"),
|
INVALID_DATABASE_TYPE_URL_PATTERN("A_10019", "不合法的 url pattern"),
|
||||||
DOCUMENT_VERSION_IS_INVALID("A_10020", "文档版本不合法"),
|
DOCUMENT_VERSION_IS_INVALID("A_10020", "文档版本不合法"),
|
||||||
CANNOT_UPDATE_SELF_ENABLED_STATUS("A_10021", "无法对自己执行启用禁用操作"),
|
CANNOT_UPDATE_SELF_ENABLED_STATUS("A_10021", "无法对自己执行启用禁用操作"),
|
||||||
|
MOCK_DATA_SCRIPT_MUST_NOT_BE_BLANK("A_10022", "脚本内容不能为空"),
|
||||||
|
TABLE_META_NOT_FOUND("A_10023", "不存在的数据库表"),
|
||||||
|
DEPENDENT_COLUMN_NAME_MUST_NOT_BE_BLANK("A_10024", "必须指定依赖的字段"),
|
||||||
|
DEPENDENT_REF_MUST_NOT_BE_BLANK("A_10025", "请选择关联表和字段"),
|
||||||
|
MUST_NOT_REF_SELF("A_10026", "不能引用自身"),
|
||||||
|
CIRCLE_REFERENCE("A_10027", "检查到循环引用"),
|
||||||
|
DUPLICATE_COLUMN("A_10028", "重复的列"),
|
||||||
|
INVALID_MOCK_DATA_SCRIPT("A_10029", "不合法的表达式"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String errCode;
|
private final String errCode;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.databasir.core.domain.document.converter;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.document.data.TableResponse;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableDocumentPojo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface TableResponseConverter {
|
||||||
|
|
||||||
|
default List<TableResponse> from(List<TableDocumentPojo> tables,
|
||||||
|
Map<Integer, List<TableColumnDocumentPojo>> columnMapByTableId) {
|
||||||
|
return tables.stream()
|
||||||
|
.map(table -> from(table, columnMapByTableId.get(table.getId())))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
TableResponse from(TableDocumentPojo table, List<TableColumnDocumentPojo> columns);
|
||||||
|
|
||||||
|
TableResponse.ColumnResponse from(TableColumnDocumentPojo column);
|
||||||
|
}
|
|
@ -16,12 +16,16 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DocumentTemplatePropertiesResponse {
|
public class DocumentTemplatePropertiesResponse {
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
private List<DocumentTemplatePropertyResponse> columnFieldNameProperties = Collections.emptyList();
|
private List<DocumentTemplatePropertyResponse> columnFieldNameProperties = Collections.emptyList();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
private List<DocumentTemplatePropertyResponse> indexFieldNameProperties = Collections.emptyList();
|
private List<DocumentTemplatePropertyResponse> indexFieldNameProperties = Collections.emptyList();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
private List<DocumentTemplatePropertyResponse> triggerFieldNameProperties = Collections.emptyList();
|
private List<DocumentTemplatePropertyResponse> triggerFieldNameProperties = Collections.emptyList();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
private List<DocumentTemplatePropertyResponse> foreignKeyFieldNameProperties = Collections.emptyList();
|
private List<DocumentTemplatePropertyResponse> foreignKeyFieldNameProperties = Collections.emptyList();
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.databasir.core.domain.document.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TableResponse {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<ColumnResponse> columns = Collections.emptyList();
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ColumnResponse {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,14 +6,8 @@ import com.databasir.core.diff.Diffs;
|
||||||
import com.databasir.core.diff.data.DiffType;
|
import com.databasir.core.diff.data.DiffType;
|
||||||
import com.databasir.core.diff.data.RootDiff;
|
import com.databasir.core.diff.data.RootDiff;
|
||||||
import com.databasir.core.domain.DomainErrors;
|
import com.databasir.core.domain.DomainErrors;
|
||||||
import com.databasir.core.domain.document.converter.DatabaseMetaConverter;
|
import com.databasir.core.domain.document.converter.*;
|
||||||
import com.databasir.core.domain.document.converter.DocumentPojoConverter;
|
import com.databasir.core.domain.document.data.*;
|
||||||
import com.databasir.core.domain.document.converter.DocumentResponseConverter;
|
|
||||||
import com.databasir.core.domain.document.converter.DocumentSimpleResponseConverter;
|
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentResponse;
|
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentSimpleResponse;
|
|
||||||
import com.databasir.core.domain.document.data.DatabaseDocumentVersionResponse;
|
|
||||||
import com.databasir.core.domain.document.data.TableDocumentResponse;
|
|
||||||
import com.databasir.core.domain.document.event.DocumentUpdated;
|
import com.databasir.core.domain.document.event.DocumentUpdated;
|
||||||
import com.databasir.core.domain.document.generator.DocumentFileGenerator;
|
import com.databasir.core.domain.document.generator.DocumentFileGenerator;
|
||||||
import com.databasir.core.domain.document.generator.DocumentFileType;
|
import com.databasir.core.domain.document.generator.DocumentFileType;
|
||||||
|
@ -82,6 +76,8 @@ public class DocumentService {
|
||||||
|
|
||||||
private final DatabaseMetaConverter databaseMetaConverter;
|
private final DatabaseMetaConverter databaseMetaConverter;
|
||||||
|
|
||||||
|
private final TableResponseConverter tableResponseConverter;
|
||||||
|
|
||||||
private final JsonConverter jsonConverter;
|
private final JsonConverter jsonConverter;
|
||||||
|
|
||||||
private final List<DocumentFileGenerator> documentFileGenerators;
|
private final List<DocumentFileGenerator> documentFileGenerators;
|
||||||
|
@ -373,4 +369,23 @@ public class DocumentService {
|
||||||
DatabaseMeta originalMeta = retrieveOriginalDatabaseMeta(original);
|
DatabaseMeta originalMeta = retrieveOriginalDatabaseMeta(original);
|
||||||
return Diffs.diff(originalMeta, currMeta);
|
return Diffs.diff(originalMeta, currMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TableResponse> getTableAndColumns(Integer projectId, Long version) {
|
||||||
|
Optional<DatabaseDocumentPojo> documentOption;
|
||||||
|
if (version == null) {
|
||||||
|
documentOption = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
|
||||||
|
} else {
|
||||||
|
documentOption = databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, version);
|
||||||
|
}
|
||||||
|
if (documentOption.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
DatabaseDocumentPojo databaseDoc = documentOption.get();
|
||||||
|
var tables = tableDocumentDao.selectByDatabaseDocumentId(databaseDoc.getId());
|
||||||
|
var columns = tableColumnDocumentDao.selectByDatabaseDocumentId(databaseDoc.getId());
|
||||||
|
var columnMapByTableId = columns.stream()
|
||||||
|
.collect(Collectors.groupingBy(TableColumnDocumentPojo::getTableDocumentId));
|
||||||
|
return tableResponseConverter.from(tables, columnMapByTableId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.databasir.core.domain.mock;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.mock.converter.MockDataRulePojoConverter;
|
||||||
|
import com.databasir.core.domain.mock.converter.MockDataRuleResponseConverter;
|
||||||
|
import com.databasir.core.domain.mock.data.ColumnMockRuleSaveRequest;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataGenerateCondition;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataRuleListCondition;
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataRuleResponse;
|
||||||
|
import com.databasir.core.domain.mock.generator.MockDataGenerator;
|
||||||
|
import com.databasir.core.domain.mock.validator.MockDataSaveValidator;
|
||||||
|
import com.databasir.core.domain.mock.validator.MockDataValidator;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.impl.MockDataRuleDao;
|
||||||
|
import com.databasir.dao.impl.TableColumnDocumentDao;
|
||||||
|
import com.databasir.dao.tables.pojos.DatabaseDocumentPojo;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableDocumentPojo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MockDataService {
|
||||||
|
|
||||||
|
private final MockDataGenerator mockDataGenerator;
|
||||||
|
|
||||||
|
private final MockDataRuleDao mockDataRuleDao;
|
||||||
|
|
||||||
|
private final TableColumnDocumentDao tableColumnDocumentDao;
|
||||||
|
|
||||||
|
private final MockDataRulePojoConverter mockDataRulePojoConverter;
|
||||||
|
|
||||||
|
private final MockDataRuleResponseConverter mockDataRuleResponseConverter;
|
||||||
|
|
||||||
|
private final MockDataSaveValidator mockDataSaveValidator;
|
||||||
|
|
||||||
|
private final MockDataValidator mockDataValidator;
|
||||||
|
|
||||||
|
public String generateMockInsertSql(Integer projectId, MockDataGenerateCondition condition) {
|
||||||
|
mockDataValidator.validProject(projectId);
|
||||||
|
DatabaseDocumentPojo databaseDoc =
|
||||||
|
mockDataValidator.validAndGetDatabaseDocumentPojo(projectId, condition.getVersion());
|
||||||
|
TableDocumentPojo tableDoc =
|
||||||
|
mockDataValidator.validAndGetTableDocumentPojo(databaseDoc.getId(), condition.getTableId());
|
||||||
|
return mockDataGenerator.createInsertSql(projectId, databaseDoc.getId(), tableDoc.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveMockRules(Integer projectId,
|
||||||
|
Integer tableId,
|
||||||
|
List<ColumnMockRuleSaveRequest> rules) {
|
||||||
|
mockDataValidator.validProject(projectId);
|
||||||
|
DatabaseDocumentPojo doc =
|
||||||
|
mockDataValidator.validAndGetDatabaseDocumentPojo(projectId, null);
|
||||||
|
TableDocumentPojo tableDoc =
|
||||||
|
mockDataValidator.validAndGetTableDocumentPojo(doc.getId(), tableId);
|
||||||
|
List<String> columnNames = rules.stream()
|
||||||
|
.map(ColumnMockRuleSaveRequest::getColumnName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
mockDataSaveValidator.validTableColumn(tableDoc.getId(), columnNames);
|
||||||
|
mockDataSaveValidator.validScriptMockType(rules);
|
||||||
|
mockDataSaveValidator.validRefMockType(doc.getId(), rules);
|
||||||
|
// verify
|
||||||
|
mockDataGenerator.createInsertSql(projectId, doc.getId(), tableDoc.getName());
|
||||||
|
|
||||||
|
List<MockDataRulePojo> pojo = mockDataRulePojoConverter.from(projectId, rules);
|
||||||
|
mockDataRuleDao.batchSave(pojo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MockDataRuleResponse> listRules(Integer projectId, MockDataRuleListCondition condition) {
|
||||||
|
mockDataValidator.validProject(projectId);
|
||||||
|
DatabaseDocumentPojo databaseDoc =
|
||||||
|
mockDataValidator.validAndGetDatabaseDocumentPojo(projectId, condition.getVersion());
|
||||||
|
TableDocumentPojo tableDoc =
|
||||||
|
mockDataValidator.validAndGetTableDocumentPojo(databaseDoc.getId(), condition.getTableId());
|
||||||
|
List<TableColumnDocumentPojo> columns =
|
||||||
|
tableColumnDocumentDao.selectByTableDocumentId(condition.getTableId());
|
||||||
|
var ruleMapByColumnName = mockDataRuleDao.selectByProjectIdAndTableName(projectId, tableDoc.getName())
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(MockDataRulePojo::getColumnName, Function.identity()));
|
||||||
|
return columns.stream()
|
||||||
|
.map(col -> {
|
||||||
|
if (ruleMapByColumnName.containsKey(col.getName())) {
|
||||||
|
return mockDataRuleResponseConverter.from(ruleMapByColumnName.get(col.getName()), col);
|
||||||
|
} else {
|
||||||
|
return mockDataRuleResponseConverter.from(tableDoc.getName(), MockDataType.AUTO, col);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.databasir.core.domain.mock.converter;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.mock.data.ColumnMockRuleSaveRequest;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface MockDataRulePojoConverter {
|
||||||
|
|
||||||
|
MockDataRulePojo from(Integer projectId, ColumnMockRuleSaveRequest request);
|
||||||
|
|
||||||
|
default List<MockDataRulePojo> from(Integer projectId, List<ColumnMockRuleSaveRequest> request) {
|
||||||
|
return request.stream()
|
||||||
|
.map(rule -> from(projectId, rule))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.databasir.core.domain.mock.converter;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.mock.data.MockDataRuleResponse;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface MockDataRuleResponseConverter {
|
||||||
|
|
||||||
|
@Mapping(target = "columnType", source = "column.type")
|
||||||
|
MockDataRuleResponse from(MockDataRulePojo pojo, TableColumnDocumentPojo column);
|
||||||
|
|
||||||
|
@Mapping(target = "columnName", source = "pojo.name")
|
||||||
|
@Mapping(target = "columnType", source = "pojo.type")
|
||||||
|
MockDataRuleResponse from(String tableName, MockDataType mockDataType, TableColumnDocumentPojo pojo);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.databasir.core.domain.mock.data;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ColumnMockRuleSaveRequest {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String columnName;
|
||||||
|
|
||||||
|
private String dependentTableName;
|
||||||
|
|
||||||
|
private String dependentColumnName;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private MockDataType mockDataType;
|
||||||
|
|
||||||
|
private String mockDataScript;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.databasir.core.domain.mock.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MockDataGenerateCondition {
|
||||||
|
|
||||||
|
private Long version;
|
||||||
|
|
||||||
|
private Integer tableId;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.databasir.core.domain.mock.data;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MockDataRuleListCondition {
|
||||||
|
|
||||||
|
private Long version;
|
||||||
|
|
||||||
|
private Integer tableId;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.databasir.core.domain.mock.data;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MockDataRuleResponse {
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
private String columnName;
|
||||||
|
|
||||||
|
private String columnType;
|
||||||
|
|
||||||
|
private String dependentTableName;
|
||||||
|
|
||||||
|
private String dependentColumnName;
|
||||||
|
|
||||||
|
private MockDataType mockDataType;
|
||||||
|
|
||||||
|
private String mockDataScript;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.databasir.core.domain.mock.factory;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.impl.TableColumnDocumentDao;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AutoMockDataFactory implements MockDataFactory {
|
||||||
|
|
||||||
|
private final TableColumnDocumentDao tableColumnDocumentDao;
|
||||||
|
|
||||||
|
public static final Map<Integer, String> DATA_TYPE_VALUE_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
DATA_TYPE_VALUE_MAP.put(9999, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.BIT, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.TINYINT, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.SMALLINT, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.INTEGER, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.BIGINT, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.FLOAT, "1.1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.REAL, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.DOUBLE, "1.2");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.NUMERIC, "1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.DECIMAL, "1.1");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.CHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.VARCHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.LONGVARCHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.DATE, "'1970-12-31'");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.TIME, "'00:00:00'");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.TIMESTAMP, "'2001-01-01 00:00:00'");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.BINARY, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.VARBINARY, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.LONGVARBINARY, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.NULL, "null");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.OTHER, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.JAVA_OBJECT, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.DISTINCT, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.STRUCT, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.ARRAY, "'{}'");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.BLOB, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.CLOB, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.REF, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.DATALINK, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.BOOLEAN, "true");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.ROWID, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.NCHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.NVARCHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.LONGNVARCHAR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.NCLOB, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.SQLXML, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.REF_CURSOR, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.TIME_WITH_TIMEZONE, "''");
|
||||||
|
DATA_TYPE_VALUE_MAP.put(Types.TIMESTAMP_WITH_TIMEZONE, "''");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(MockColumnRule rule) {
|
||||||
|
return rule == null || rule.getMockDataType() == MockDataType.AUTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String create(MockColumnRule rule) {
|
||||||
|
return DATA_TYPE_VALUE_MAP.getOrDefault(rule.getDataType(), "''");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.databasir.core.domain.mock.factory;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.github.javafaker.Faker;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.StringJoiner;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order(0)
|
||||||
|
public class FakerMockDataFactory implements MockDataFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(MockColumnRule rule) {
|
||||||
|
return MockDataType.fakerTypes().contains(rule.getMockDataType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String create(MockColumnRule rule) {
|
||||||
|
Faker faker = new Faker();
|
||||||
|
StringJoiner joiner = new StringJoiner("", "'", "'");
|
||||||
|
switch (rule.getMockDataType()) {
|
||||||
|
case FULL_NAME:
|
||||||
|
joiner.add(faker.name().username());
|
||||||
|
return joiner.toString();
|
||||||
|
case PHONE:
|
||||||
|
joiner.add(faker.phoneNumber().cellPhone());
|
||||||
|
return joiner.toString();
|
||||||
|
case FULL_ADDRESS:
|
||||||
|
joiner.add(faker.address().fullAddress());
|
||||||
|
return joiner.toString();
|
||||||
|
case AVATAR_URL:
|
||||||
|
joiner.add(faker.avatar().image());
|
||||||
|
return joiner.toString();
|
||||||
|
case UUID:
|
||||||
|
joiner.add(UUID.randomUUID().toString());
|
||||||
|
return joiner.toString();
|
||||||
|
case EMAIL:
|
||||||
|
joiner.add(faker.name().username() + "@generated" + UUID.randomUUID().toString()
|
||||||
|
.replace("-", "").toString());
|
||||||
|
return joiner.toString();
|
||||||
|
default:
|
||||||
|
return "''";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.databasir.core.domain.mock.factory;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class MockColumnRule {
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
private String columnName;
|
||||||
|
|
||||||
|
private String columnType;
|
||||||
|
|
||||||
|
private Integer dataType;
|
||||||
|
|
||||||
|
private MockDataType mockDataType;
|
||||||
|
|
||||||
|
private String mockDataScript;
|
||||||
|
|
||||||
|
public static MockColumnRule auto(String tableName, String columnName) {
|
||||||
|
return MockColumnRule.builder()
|
||||||
|
.tableName(tableName)
|
||||||
|
.columnName(columnName)
|
||||||
|
.mockDataType(MockDataType.AUTO)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getMockDataScript() {
|
||||||
|
return Optional.ofNullable(mockDataScript);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.databasir.core.domain.mock.factory;
|
||||||
|
|
||||||
|
public interface MockDataFactory {
|
||||||
|
|
||||||
|
boolean accept(MockColumnRule rule);
|
||||||
|
|
||||||
|
String create(MockColumnRule rule);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.databasir.core.domain.mock.factory;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.mock.script.MockScriptEvaluator;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Order(0)
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ScriptMockDataFactory implements MockDataFactory {
|
||||||
|
|
||||||
|
private final MockScriptEvaluator mockScriptEvaluator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(MockColumnRule rule) {
|
||||||
|
return rule.getMockDataType() == MockDataType.SCRIPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String create(MockColumnRule rule) {
|
||||||
|
return mockScriptEvaluator.evaluate(rule.getMockDataScript().get(), new MockScriptEvaluator.ScriptContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.databasir.core.domain.mock.generator;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class ColumnMockData {
|
||||||
|
|
||||||
|
private String columnName;
|
||||||
|
|
||||||
|
private String columnType;
|
||||||
|
|
||||||
|
private String mockData;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,173 @@
|
||||||
|
package com.databasir.core.domain.mock.generator;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.DomainErrors;
|
||||||
|
import com.databasir.dao.exception.DataNotExistsException;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class MockDataContext {
|
||||||
|
|
||||||
|
private Integer projectId;
|
||||||
|
|
||||||
|
private Integer databaseDocumentId;
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, TableMockData> tableMockDataMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, Set<String>> fromReference = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, Set<String>> toReference = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, Map<String, MockDataRulePojo>> ruleMap = new LinkedHashMap<>(16);
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, Map<String, TableColumnDocumentPojo>> tableColumnMap = new LinkedHashMap<>(16);
|
||||||
|
|
||||||
|
@Builder.Default
|
||||||
|
private Map<String, Set<String>> mockInProgress = new HashMap<>();
|
||||||
|
|
||||||
|
public void addTableMockRules(String tableName, List<MockDataRulePojo> rules) {
|
||||||
|
var columnRuleMap = rules.stream()
|
||||||
|
.collect(Collectors.toMap(MockDataRulePojo::getColumnName, Function.identity()));
|
||||||
|
this.ruleMap.put(tableName, columnRuleMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containMockRule(String tableName) {
|
||||||
|
return ruleMap.containsKey(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containMockRule(String tableName, String columnName) {
|
||||||
|
if (!ruleMap.containsKey(tableName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ruleMap.get(tableName).containsKey(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<MockDataRulePojo> getMockRule(String tableName, String columnName) {
|
||||||
|
if (!ruleMap.containsKey(tableName)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(ruleMap.get(tableName).get(columnName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTableColumns(String tableName, List<TableColumnDocumentPojo> columns) {
|
||||||
|
Map<String, TableColumnDocumentPojo> columnMap = new LinkedHashMap<>();
|
||||||
|
for (TableColumnDocumentPojo column : columns) {
|
||||||
|
columnMap.put(column.getName(), column);
|
||||||
|
}
|
||||||
|
this.tableColumnMap.put(tableName, columnMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsTable(String tableName) {
|
||||||
|
return tableColumnMap.containsKey(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsTableColumn(String tableName, String columnName) {
|
||||||
|
if (!tableColumnMap.containsKey(tableName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return tableColumnMap.get(tableName).containsKey(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableColumnDocumentPojo getTableColumn(String tableName, String columnName) {
|
||||||
|
if (!tableColumnMap.containsKey(tableName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tableColumnMap.get(tableName).get(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsTableMockData(String tableName) {
|
||||||
|
return tableMockDataMap.containsKey(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsColumnMockData(String tableName, String columName) {
|
||||||
|
return tableMockDataMap.containsKey(tableName) && tableMockDataMap.get(tableName).containsColumn(columName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTableMockData(TableMockData tableMockData) {
|
||||||
|
this.tableMockDataMap.put(tableMockData.getTableName(), tableMockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableMockData getTableMockData(String tableName) {
|
||||||
|
return this.tableMockDataMap.get(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addColumnMockData(String tableName, ColumnMockData columnMockData) {
|
||||||
|
TableMockData mock =
|
||||||
|
tableMockDataMap.computeIfAbsent(tableName, key -> TableMockData.of(tableName, new ArrayList<>()));
|
||||||
|
mock.addColumnIfNotExists(columnMockData);
|
||||||
|
// sort to last
|
||||||
|
tableMockDataMap.remove(tableName);
|
||||||
|
tableMockDataMap.put(tableName, mock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRawColumnMockData(String tableName, String columnName) {
|
||||||
|
if (!this.containsTableMockData(tableName)) {
|
||||||
|
throw new DataNotExistsException("can't find table mock data by " + tableName);
|
||||||
|
}
|
||||||
|
return getTableMockData(tableName)
|
||||||
|
.getColumnMockData()
|
||||||
|
.stream()
|
||||||
|
.filter(t -> t.getColumnName().equals(columnName))
|
||||||
|
.findFirst()
|
||||||
|
.map(ColumnMockData::getMockData)
|
||||||
|
.orElseThrow(DataNotExistsException::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMockInProgress(String tableName, String columnName) {
|
||||||
|
return this.mockInProgress.containsKey(tableName) && this.mockInProgress.get(tableName).contains(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMockInProgress(String tableName, String columnName) {
|
||||||
|
Set<String> inProgress = this.mockInProgress.computeIfAbsent(tableName, key -> new HashSet<>());
|
||||||
|
inProgress.add(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMockInProgress(String tableName, String columnName) {
|
||||||
|
Set<String> inProgress = this.mockInProgress.computeIfAbsent(tableName, key -> new HashSet<>());
|
||||||
|
inProgress.remove(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toInsertSql() {
|
||||||
|
return tableMockDataMap.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(entry -> {
|
||||||
|
String tableName = entry.getKey();
|
||||||
|
List<ColumnMockData> columns = entry.getValue().getColumnMockData();
|
||||||
|
String format = "insert into %s (%s)\nvalues\n(%s);";
|
||||||
|
String columnNames = columns.stream()
|
||||||
|
.map(c -> "" + c.getColumnName() + "")
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
String columnValues = columns.stream()
|
||||||
|
.map(ColumnMockData::getMockData)
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
return String.format(format, tableName, columnNames, columnValues);
|
||||||
|
})
|
||||||
|
.collect(Collectors.joining("\n\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveReference(String fromTable, String fromColumn, String toTable, String toColumn) {
|
||||||
|
if (toReference.containsKey(fromTable) && toReference.get(fromTable).contains(fromColumn)) {
|
||||||
|
if (fromReference.containsKey(toTable) && fromReference.get(toTable).contains(toColumn)) {
|
||||||
|
String format = "%s 和 %s 出现了循环引用";
|
||||||
|
String message = String.format(format, fromTable + "." + fromColumn, toTable + "." + toColumn);
|
||||||
|
throw DomainErrors.CIRCLE_REFERENCE.exception(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Set<String> fromColumns = this.fromReference.computeIfAbsent(fromTable, key -> new HashSet<>());
|
||||||
|
fromColumns.add(fromColumn);
|
||||||
|
Set<String> toColumns = this.toReference.computeIfAbsent(toTable, key -> new HashSet<>());
|
||||||
|
toColumns.add(toColumn);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
package com.databasir.core.domain.mock.generator;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.DomainErrors;
|
||||||
|
import com.databasir.core.domain.mock.factory.MockColumnRule;
|
||||||
|
import com.databasir.core.domain.mock.factory.MockDataFactory;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.impl.MockDataRuleDao;
|
||||||
|
import com.databasir.dao.impl.ProjectDao;
|
||||||
|
import com.databasir.dao.impl.TableColumnDocumentDao;
|
||||||
|
import com.databasir.dao.impl.TableDocumentDao;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class MockDataGenerator {
|
||||||
|
|
||||||
|
private final List<MockDataFactory> mockDataFactories;
|
||||||
|
|
||||||
|
private final MockDataRuleDao mockDataRuleDao;
|
||||||
|
|
||||||
|
private final TableDocumentDao tableDocumentDao;
|
||||||
|
|
||||||
|
private final TableColumnDocumentDao tableColumnDocumentDao;
|
||||||
|
|
||||||
|
private final ProjectDao projectDao;
|
||||||
|
|
||||||
|
public String createInsertSql(Integer projectId,
|
||||||
|
Integer databaseDocId,
|
||||||
|
String tableName) {
|
||||||
|
if (!projectDao.existsById(projectId)) {
|
||||||
|
throw DomainErrors.PROJECT_NOT_FOUND.exception();
|
||||||
|
}
|
||||||
|
MockDataContext context = MockDataContext.builder()
|
||||||
|
.databaseDocumentId(databaseDocId)
|
||||||
|
.projectId(projectId)
|
||||||
|
.build();
|
||||||
|
create(context, tableName);
|
||||||
|
return context.toInsertSql();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create(MockDataContext context, String tableName) {
|
||||||
|
if (!context.containsTable(tableName)) {
|
||||||
|
var tableOption =
|
||||||
|
tableDocumentDao.selectByDatabaseDocumentIdAndTableName(context.getDatabaseDocumentId(), tableName);
|
||||||
|
if (tableOption.isEmpty()) {
|
||||||
|
log.warn("can not find table => " + tableName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var table = tableOption.get();
|
||||||
|
var columns = tableColumnDocumentDao.selectByTableDocumentId(table.getId());
|
||||||
|
context.addTableColumns(tableName, columns);
|
||||||
|
}
|
||||||
|
if (!context.containMockRule(tableName)) {
|
||||||
|
var columnRules = mockDataRuleDao.selectByProjectIdAndTableName(context.getProjectId(), tableName);
|
||||||
|
context.addTableMockRules(tableName, columnRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TableColumnDocumentPojo column : context.getTableColumnMap().get(tableName).values()) {
|
||||||
|
if (context.containsColumnMockData(tableName, column.getName())
|
||||||
|
|| context.isMockInProgress(tableName, column.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
create(context, tableName, column.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create(MockDataContext context, String tableName, String columnName) {
|
||||||
|
if (context.containsColumnMockData(tableName, columnName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TableColumnDocumentPojo column = context.getTableColumn(tableName, columnName);
|
||||||
|
Optional<MockDataRulePojo> ruleOption = context.getMockRule(tableName, columnName);
|
||||||
|
String rawData;
|
||||||
|
if (ruleOption.isPresent()) {
|
||||||
|
MockDataRulePojo rule = ruleOption.get();
|
||||||
|
if (rule.getMockDataType() == MockDataType.REF) {
|
||||||
|
context.addMockInProgress(tableName, columnName);
|
||||||
|
context.saveReference(
|
||||||
|
rule.getTableName(), rule.getColumnName(),
|
||||||
|
rule.getDependentTableName(), rule.getDependentColumnName()
|
||||||
|
);
|
||||||
|
if (context.containsTable(rule.getDependentTableName())) {
|
||||||
|
create(context, rule.getDependentTableName(), rule.getDependentColumnName());
|
||||||
|
} else {
|
||||||
|
create(context, rule.getDependentTableName());
|
||||||
|
}
|
||||||
|
context.removeMockInProgress(tableName, columnName);
|
||||||
|
rawData = context.getRawColumnMockData(rule.getDependentTableName(), rule.getDependentColumnName());
|
||||||
|
} else {
|
||||||
|
rawData = createByFactory(column, rule);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rawData = createByFactory(column, null);
|
||||||
|
}
|
||||||
|
context.addColumnMockData(tableName, toData(rawData, column));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createByFactory(TableColumnDocumentPojo column, MockDataRulePojo rule) {
|
||||||
|
MockDataType mockType = rule == null ? MockDataType.AUTO : rule.getMockDataType();
|
||||||
|
MockColumnRule colRule = MockColumnRule.builder()
|
||||||
|
.dataType(column.getDataType())
|
||||||
|
.mockDataType(mockType)
|
||||||
|
.mockDataScript(null == rule ? null : rule.getMockDataScript())
|
||||||
|
.columnName(column.getName())
|
||||||
|
.columnType(column.getType())
|
||||||
|
.build();
|
||||||
|
return mockDataFactories.stream()
|
||||||
|
.filter(factory -> factory.accept(colRule))
|
||||||
|
.findFirst()
|
||||||
|
.map(factory -> factory.create(colRule))
|
||||||
|
.orElseThrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColumnMockData toData(String data, TableColumnDocumentPojo column) {
|
||||||
|
return ColumnMockData.builder()
|
||||||
|
.columnName(column.getName())
|
||||||
|
.columnType(column.getType())
|
||||||
|
.mockData(data)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.databasir.core.domain.mock.generator;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TableMockData {
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
private List<ColumnMockData> columnMockData;
|
||||||
|
|
||||||
|
public static TableMockData of(String tableName, List<ColumnMockData> columnMockData) {
|
||||||
|
return new TableMockData(tableName, columnMockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addColumnIfNotExists(ColumnMockData data) {
|
||||||
|
boolean present = columnMockData.stream()
|
||||||
|
.anyMatch(col -> Objects.equals(col.getColumnName(), data.getColumnName()));
|
||||||
|
if (present) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.columnMockData.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsColumn(String columnName) {
|
||||||
|
return columnMockData.stream()
|
||||||
|
.anyMatch(col -> Objects.equals(col.getColumnName(), columnName));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.databasir.core.domain.mock.script;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
public interface MockScriptEvaluator {
|
||||||
|
|
||||||
|
String evaluate(String script, ScriptContext context);
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class ScriptContext {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.databasir.core.domain.mock.script;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.expression.Expression;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SpelScriptEvaluator implements MockScriptEvaluator {
|
||||||
|
|
||||||
|
private final SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String evaluate(String script, ScriptContext context) {
|
||||||
|
Expression expression = spelExpressionParser.parseExpression(script);
|
||||||
|
StandardEvaluationContext spelContext = new StandardEvaluationContext(context);
|
||||||
|
return expression.getValue(spelContext, String.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package com.databasir.core.domain.mock.validator;
|
||||||
|
|
||||||
|
import com.alibaba.excel.util.StringUtils;
|
||||||
|
import com.databasir.core.domain.DomainErrors;
|
||||||
|
import com.databasir.core.domain.mock.data.ColumnMockRuleSaveRequest;
|
||||||
|
import com.databasir.core.domain.mock.script.MockScriptEvaluator;
|
||||||
|
import com.databasir.core.domain.mock.script.SpelScriptEvaluator;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.impl.TableColumnDocumentDao;
|
||||||
|
import com.databasir.dao.impl.TableDocumentDao;
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MockDataSaveValidator {
|
||||||
|
|
||||||
|
private final TableDocumentDao tableDocumentDao;
|
||||||
|
|
||||||
|
private final TableColumnDocumentDao tableColumnDocumentDao;
|
||||||
|
|
||||||
|
private final SpelScriptEvaluator spelScriptEvaluator;
|
||||||
|
|
||||||
|
public void validScriptMockType(List<ColumnMockRuleSaveRequest> rules) {
|
||||||
|
for (ColumnMockRuleSaveRequest request : rules) {
|
||||||
|
if (request.getMockDataType() != MockDataType.SCRIPT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(request.getMockDataScript())) {
|
||||||
|
throw DomainErrors.MOCK_DATA_SCRIPT_MUST_NOT_BE_BLANK.exception();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
spelScriptEvaluator.evaluate(request.getMockDataScript(), new MockScriptEvaluator.ScriptContext());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw DomainErrors.INVALID_MOCK_DATA_SCRIPT.exception(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validTableColumn(Integer tableDocId, List<String> requestColumnNames) {
|
||||||
|
var existsColumnNames = tableColumnDocumentDao.selectByTableDocumentId(tableDocId)
|
||||||
|
.stream()
|
||||||
|
.map(TableColumnDocumentPojo::getName)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
for (String colName : requestColumnNames) {
|
||||||
|
if (!existsColumnNames.contains(colName)) {
|
||||||
|
throw DomainErrors.TABLE_META_NOT_FOUND.exception("column "
|
||||||
|
+ colName
|
||||||
|
+ " not exists in "
|
||||||
|
+ tableDocId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validRefMockType(Integer databaseDocId,
|
||||||
|
List<ColumnMockRuleSaveRequest> rules) {
|
||||||
|
Map<String, Set<String>> fromTableAndColumn = new HashMap<>();
|
||||||
|
Map<String, Set<String>> toTableAndColumn = new HashMap<>();
|
||||||
|
for (ColumnMockRuleSaveRequest request : rules) {
|
||||||
|
if (request.getMockDataType() != MockDataType.REF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
forbiddenIfMissRequireParams(request);
|
||||||
|
forbiddenIfSelfReference(request);
|
||||||
|
forbiddenIfCircleReference(request, fromTableAndColumn, toTableAndColumn);
|
||||||
|
forbiddenIfIsInvalidTableOrColumn(databaseDocId, request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forbiddenIfSelfReference(ColumnMockRuleSaveRequest request) {
|
||||||
|
if (!Objects.equals(request.getTableName(), request.getDependentTableName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(request.getColumnName(), request.getDependentColumnName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw DomainErrors.MUST_NOT_REF_SELF.exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forbiddenIfMissRequireParams(ColumnMockRuleSaveRequest request) {
|
||||||
|
if (StringUtils.isBlank(request.getDependentTableName())) {
|
||||||
|
throw DomainErrors.DEPENDENT_COLUMN_NAME_MUST_NOT_BE_BLANK.exception();
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(request.getDependentColumnName())) {
|
||||||
|
throw DomainErrors.DEPENDENT_COLUMN_NAME_MUST_NOT_BE_BLANK.exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forbiddenIfIsInvalidTableOrColumn(Integer docId, ColumnMockRuleSaveRequest request) {
|
||||||
|
String dependentTableName = request.getDependentTableName();
|
||||||
|
var dependentTable = tableDocumentDao.selectByDatabaseDocumentIdAndTableName(docId, dependentTableName)
|
||||||
|
.orElseThrow(DomainErrors.TABLE_META_NOT_FOUND::exception);
|
||||||
|
if (!tableColumnDocumentDao.exists(dependentTable.getId(), request.getDependentColumnName())) {
|
||||||
|
throw DomainErrors.TABLE_META_NOT_FOUND.exception("列字段 "
|
||||||
|
+ request.getDependentColumnName()
|
||||||
|
+ "不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forbiddenIfCircleReference(ColumnMockRuleSaveRequest request,
|
||||||
|
Map<String, Set<String>> fromTableAndColumn,
|
||||||
|
Map<String, Set<String>> toTableAndColumn) {
|
||||||
|
if (toTableAndColumn.containsKey(request.getTableName())
|
||||||
|
&& toTableAndColumn.get(request.getTableName()).contains(request.getColumnName())) {
|
||||||
|
if (fromTableAndColumn.containsKey(request.getDependentTableName())
|
||||||
|
&& fromTableAndColumn.get(request.getDependentTableName())
|
||||||
|
.contains(request.getDependentColumnName())) {
|
||||||
|
String format = "%s 和 %s 出现了循环引用";
|
||||||
|
String from = request.getTableName() + "." + request.getColumnName();
|
||||||
|
String to = request.getDependentTableName() + "." + request.getDependentColumnName();
|
||||||
|
String message = String.format(format, from, to);
|
||||||
|
throw DomainErrors.CIRCLE_REFERENCE.exception(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> fromColumns =
|
||||||
|
fromTableAndColumn.computeIfAbsent(request.getTableName(), key -> new HashSet<String>());
|
||||||
|
fromColumns.add(request.getColumnName());
|
||||||
|
Set<String> toColumns =
|
||||||
|
toTableAndColumn.computeIfAbsent(request.getDependentTableName(), key -> new HashSet<String>());
|
||||||
|
toColumns.add(request.getDependentColumnName());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.databasir.core.domain.mock.validator;
|
||||||
|
|
||||||
|
import com.databasir.core.domain.DomainErrors;
|
||||||
|
import com.databasir.dao.impl.DatabaseDocumentDao;
|
||||||
|
import com.databasir.dao.impl.ProjectDao;
|
||||||
|
import com.databasir.dao.impl.TableDocumentDao;
|
||||||
|
import com.databasir.dao.tables.pojos.DatabaseDocumentPojo;
|
||||||
|
import com.databasir.dao.tables.pojos.TableDocumentPojo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MockDataValidator {
|
||||||
|
|
||||||
|
private final ProjectDao projectDao;
|
||||||
|
|
||||||
|
private final DatabaseDocumentDao databaseDocumentDao;
|
||||||
|
|
||||||
|
private final TableDocumentDao tableDocumentDao;
|
||||||
|
|
||||||
|
public void validProject(Integer projectId) {
|
||||||
|
if (!projectDao.existsById(projectId)) {
|
||||||
|
throw DomainErrors.PROJECT_NOT_FOUND.exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatabaseDocumentPojo validAndGetDatabaseDocumentPojo(Integer projectId, Long version) {
|
||||||
|
Optional<DatabaseDocumentPojo> databaseDoc;
|
||||||
|
if (version == null) {
|
||||||
|
databaseDoc = databaseDocumentDao.selectNotArchivedByProjectId(projectId);
|
||||||
|
} else {
|
||||||
|
databaseDoc = databaseDocumentDao.selectOptionalByProjectIdAndVersion(projectId, version);
|
||||||
|
}
|
||||||
|
if (databaseDoc.isEmpty()) {
|
||||||
|
throw DomainErrors.DATABASE_META_NOT_FOUND.exception();
|
||||||
|
}
|
||||||
|
return databaseDoc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableDocumentPojo validAndGetTableDocumentPojo(Integer databaseDocId, Integer tableId) {
|
||||||
|
Optional<TableDocumentPojo> tableOption =
|
||||||
|
tableDocumentDao.selectByDatabaseDocumentIdAndId(databaseDocId, tableId);
|
||||||
|
if (tableOption.isEmpty()) {
|
||||||
|
throw DomainErrors.DATABASE_META_NOT_FOUND.exception("表数据不存在");
|
||||||
|
}
|
||||||
|
return tableOption.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.databasir.core.domain.mock.service;
|
||||||
|
|
||||||
|
import com.databasir.core.BaseTest;
|
||||||
|
import com.databasir.core.domain.mock.MockDataService;
|
||||||
|
import com.databasir.core.domain.mock.generator.MockDataGenerator;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public class MockDataServiceTest extends BaseTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockDataService mockDataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockDataGenerator mockDataGenerator;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
String sql = mockDataGenerator.createInsertSql(15,3L, "event_reward_history");
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,6 +72,12 @@ jooq {
|
||||||
includeExpression = 'document_template_property.type'
|
includeExpression = 'document_template_property.type'
|
||||||
includeTypes = '.*'
|
includeTypes = '.*'
|
||||||
}
|
}
|
||||||
|
forcedType {
|
||||||
|
userType = 'com.databasir.dao.enums.MockDataType'
|
||||||
|
converter = 'com.databasir.dao.converter.MockDataTypeConverter'
|
||||||
|
includeExpression = 'mock_data_rule.mock_data_type'
|
||||||
|
includeTypes = '.*'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generate {
|
generate {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.databasir.dao.tables.DocumentDiscussion;
|
||||||
import com.databasir.dao.tables.DocumentTemplateProperty;
|
import com.databasir.dao.tables.DocumentTemplateProperty;
|
||||||
import com.databasir.dao.tables.Group;
|
import com.databasir.dao.tables.Group;
|
||||||
import com.databasir.dao.tables.Login;
|
import com.databasir.dao.tables.Login;
|
||||||
|
import com.databasir.dao.tables.MockDataRule;
|
||||||
import com.databasir.dao.tables.OauthApp;
|
import com.databasir.dao.tables.OauthApp;
|
||||||
import com.databasir.dao.tables.OperationLog;
|
import com.databasir.dao.tables.OperationLog;
|
||||||
import com.databasir.dao.tables.Project;
|
import com.databasir.dao.tables.Project;
|
||||||
|
@ -94,6 +95,11 @@ public class Databasir extends SchemaImpl {
|
||||||
*/
|
*/
|
||||||
public final Login LOGIN = Login.LOGIN;
|
public final Login LOGIN = Login.LOGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table <code>databasir.mock_data_rule</code>.
|
||||||
|
*/
|
||||||
|
public final MockDataRule MOCK_DATA_RULE = MockDataRule.MOCK_DATA_RULE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oauth app info
|
* oauth app info
|
||||||
*/
|
*/
|
||||||
|
@ -189,6 +195,7 @@ public class Databasir extends SchemaImpl {
|
||||||
DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY,
|
DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY,
|
||||||
Group.GROUP,
|
Group.GROUP,
|
||||||
Login.LOGIN,
|
Login.LOGIN,
|
||||||
|
MockDataRule.MOCK_DATA_RULE,
|
||||||
OauthApp.OAUTH_APP,
|
OauthApp.OAUTH_APP,
|
||||||
OperationLog.OPERATION_LOG,
|
OperationLog.OPERATION_LOG,
|
||||||
Project.PROJECT,
|
Project.PROJECT,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.databasir.dao.tables.DocumentDiscussion;
|
||||||
import com.databasir.dao.tables.DocumentTemplateProperty;
|
import com.databasir.dao.tables.DocumentTemplateProperty;
|
||||||
import com.databasir.dao.tables.Group;
|
import com.databasir.dao.tables.Group;
|
||||||
import com.databasir.dao.tables.Login;
|
import com.databasir.dao.tables.Login;
|
||||||
|
import com.databasir.dao.tables.MockDataRule;
|
||||||
import com.databasir.dao.tables.OauthApp;
|
import com.databasir.dao.tables.OauthApp;
|
||||||
import com.databasir.dao.tables.OperationLog;
|
import com.databasir.dao.tables.OperationLog;
|
||||||
import com.databasir.dao.tables.Project;
|
import com.databasir.dao.tables.Project;
|
||||||
|
@ -36,6 +37,7 @@ import com.databasir.dao.tables.records.DocumentDiscussionRecord;
|
||||||
import com.databasir.dao.tables.records.DocumentTemplatePropertyRecord;
|
import com.databasir.dao.tables.records.DocumentTemplatePropertyRecord;
|
||||||
import com.databasir.dao.tables.records.GroupRecord;
|
import com.databasir.dao.tables.records.GroupRecord;
|
||||||
import com.databasir.dao.tables.records.LoginRecord;
|
import com.databasir.dao.tables.records.LoginRecord;
|
||||||
|
import com.databasir.dao.tables.records.MockDataRuleRecord;
|
||||||
import com.databasir.dao.tables.records.OauthAppRecord;
|
import com.databasir.dao.tables.records.OauthAppRecord;
|
||||||
import com.databasir.dao.tables.records.OperationLogRecord;
|
import com.databasir.dao.tables.records.OperationLogRecord;
|
||||||
import com.databasir.dao.tables.records.ProjectRecord;
|
import com.databasir.dao.tables.records.ProjectRecord;
|
||||||
|
@ -82,6 +84,8 @@ public class Keys {
|
||||||
public static final UniqueKey<GroupRecord> KEY_GROUP_PRIMARY = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_PRIMARY"), new TableField[] { Group.GROUP.ID }, true);
|
public static final UniqueKey<GroupRecord> KEY_GROUP_PRIMARY = Internal.createUniqueKey(Group.GROUP, DSL.name("KEY_group_PRIMARY"), new TableField[] { Group.GROUP.ID }, true);
|
||||||
public static final UniqueKey<LoginRecord> KEY_LOGIN_PRIMARY = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_PRIMARY"), new TableField[] { Login.LOGIN.ID }, true);
|
public static final UniqueKey<LoginRecord> KEY_LOGIN_PRIMARY = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_PRIMARY"), new TableField[] { Login.LOGIN.ID }, true);
|
||||||
public static final UniqueKey<LoginRecord> KEY_LOGIN_UK_USER_ID = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_uk_user_id"), new TableField[] { Login.LOGIN.USER_ID }, true);
|
public static final UniqueKey<LoginRecord> KEY_LOGIN_UK_USER_ID = Internal.createUniqueKey(Login.LOGIN, DSL.name("KEY_login_uk_user_id"), new TableField[] { Login.LOGIN.USER_ID }, true);
|
||||||
|
public static final UniqueKey<MockDataRuleRecord> KEY_MOCK_DATA_RULE_PRIMARY = Internal.createUniqueKey(MockDataRule.MOCK_DATA_RULE, DSL.name("KEY_mock_data_rule_PRIMARY"), new TableField[] { MockDataRule.MOCK_DATA_RULE.ID }, true);
|
||||||
|
public static final UniqueKey<MockDataRuleRecord> KEY_MOCK_DATA_RULE_UK_PROJECT_ID_TABLE_NAME_COLUMN_NAME = Internal.createUniqueKey(MockDataRule.MOCK_DATA_RULE, DSL.name("KEY_mock_data_rule_uk_project_id_table_name_column_name"), new TableField[] { MockDataRule.MOCK_DATA_RULE.PROJECT_ID, MockDataRule.MOCK_DATA_RULE.TABLE_NAME, MockDataRule.MOCK_DATA_RULE.COLUMN_NAME }, true);
|
||||||
public static final UniqueKey<OauthAppRecord> KEY_OAUTH_APP_PRIMARY = Internal.createUniqueKey(OauthApp.OAUTH_APP, DSL.name("KEY_oauth_app_PRIMARY"), new TableField[] { OauthApp.OAUTH_APP.ID }, true);
|
public static final UniqueKey<OauthAppRecord> KEY_OAUTH_APP_PRIMARY = Internal.createUniqueKey(OauthApp.OAUTH_APP, DSL.name("KEY_oauth_app_PRIMARY"), new TableField[] { OauthApp.OAUTH_APP.ID }, true);
|
||||||
public static final UniqueKey<OauthAppRecord> KEY_OAUTH_APP_UK_REGISTRATION_ID = Internal.createUniqueKey(OauthApp.OAUTH_APP, DSL.name("KEY_oauth_app_uk_registration_id"), new TableField[] { OauthApp.OAUTH_APP.REGISTRATION_ID }, true);
|
public static final UniqueKey<OauthAppRecord> KEY_OAUTH_APP_UK_REGISTRATION_ID = Internal.createUniqueKey(OauthApp.OAUTH_APP, DSL.name("KEY_oauth_app_uk_registration_id"), new TableField[] { OauthApp.OAUTH_APP.REGISTRATION_ID }, true);
|
||||||
public static final UniqueKey<OperationLogRecord> KEY_OPERATION_LOG_PRIMARY = Internal.createUniqueKey(OperationLog.OPERATION_LOG, DSL.name("KEY_operation_log_PRIMARY"), new TableField[] { OperationLog.OPERATION_LOG.ID }, true);
|
public static final UniqueKey<OperationLogRecord> KEY_OPERATION_LOG_PRIMARY = Internal.createUniqueKey(OperationLog.OPERATION_LOG, DSL.name("KEY_operation_log_PRIMARY"), new TableField[] { OperationLog.OPERATION_LOG.ID }, true);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.databasir.dao.tables.DocumentDiscussion;
|
||||||
import com.databasir.dao.tables.DocumentTemplateProperty;
|
import com.databasir.dao.tables.DocumentTemplateProperty;
|
||||||
import com.databasir.dao.tables.Group;
|
import com.databasir.dao.tables.Group;
|
||||||
import com.databasir.dao.tables.Login;
|
import com.databasir.dao.tables.Login;
|
||||||
|
import com.databasir.dao.tables.MockDataRule;
|
||||||
import com.databasir.dao.tables.OauthApp;
|
import com.databasir.dao.tables.OauthApp;
|
||||||
import com.databasir.dao.tables.OperationLog;
|
import com.databasir.dao.tables.OperationLog;
|
||||||
import com.databasir.dao.tables.Project;
|
import com.databasir.dao.tables.Project;
|
||||||
|
@ -80,6 +81,11 @@ public class Tables {
|
||||||
*/
|
*/
|
||||||
public static final Login LOGIN = Login.LOGIN;
|
public static final Login LOGIN = Login.LOGIN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table <code>databasir.mock_data_rule</code>.
|
||||||
|
*/
|
||||||
|
public static final MockDataRule MOCK_DATA_RULE = MockDataRule.MOCK_DATA_RULE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oauth app info
|
* oauth app info
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
/*
|
||||||
|
* This file is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
package com.databasir.dao.tables;
|
||||||
|
|
||||||
|
|
||||||
|
import com.databasir.dao.Databasir;
|
||||||
|
import com.databasir.dao.Keys;
|
||||||
|
import com.databasir.dao.converter.MockDataTypeConverter;
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.tables.records.MockDataRuleRecord;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jooq.Field;
|
||||||
|
import org.jooq.ForeignKey;
|
||||||
|
import org.jooq.Identity;
|
||||||
|
import org.jooq.Name;
|
||||||
|
import org.jooq.Record;
|
||||||
|
import org.jooq.Row10;
|
||||||
|
import org.jooq.Schema;
|
||||||
|
import org.jooq.Table;
|
||||||
|
import org.jooq.TableField;
|
||||||
|
import org.jooq.TableOptions;
|
||||||
|
import org.jooq.UniqueKey;
|
||||||
|
import org.jooq.impl.DSL;
|
||||||
|
import org.jooq.impl.SQLDataType;
|
||||||
|
import org.jooq.impl.TableImpl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
|
public class MockDataRule extends TableImpl<MockDataRuleRecord> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reference instance of <code>databasir.mock_data_rule</code>
|
||||||
|
*/
|
||||||
|
public static final MockDataRule MOCK_DATA_RULE = new MockDataRule();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class holding records for this type
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Class<MockDataRuleRecord> getRecordType() {
|
||||||
|
return MockDataRuleRecord.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.id</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.project_id</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, Integer> PROJECT_ID = createField(DSL.name("project_id"), SQLDataType.INTEGER.nullable(false), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.table_name</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, String> TABLE_NAME = createField(DSL.name("table_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.column_name</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, String> COLUMN_NAME = createField(DSL.name("column_name"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.dependent_table_name</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, String> DEPENDENT_TABLE_NAME = createField(DSL.name("dependent_table_name"), SQLDataType.VARCHAR(255), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.dependent_column_name</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, String> DEPENDENT_COLUMN_NAME = createField(DSL.name("dependent_column_name"), SQLDataType.VARCHAR(255), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.mock_data_type</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, MockDataType> MOCK_DATA_TYPE = createField(DSL.name("mock_data_type"), SQLDataType.VARCHAR(255).nullable(false).defaultValue(DSL.inline("AUTO / REF / SCRIPT / PHONE / DATE / TIMESTAMP / ...", SQLDataType.VARCHAR)), this, "", new MockDataTypeConverter());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.mock_data_script</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, String> MOCK_DATA_SCRIPT = createField(DSL.name("mock_data_script"), SQLDataType.CLOB, this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.update_at</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, LocalDateTime> UPDATE_AT = createField(DSL.name("update_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.mock_data_rule.create_at</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<MockDataRuleRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, "");
|
||||||
|
|
||||||
|
private MockDataRule(Name alias, Table<MockDataRuleRecord> aliased) {
|
||||||
|
this(alias, aliased, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MockDataRule(Name alias, Table<MockDataRuleRecord> aliased, Field<?>[] parameters) {
|
||||||
|
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an aliased <code>databasir.mock_data_rule</code> table reference
|
||||||
|
*/
|
||||||
|
public MockDataRule(String alias) {
|
||||||
|
this(DSL.name(alias), MOCK_DATA_RULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an aliased <code>databasir.mock_data_rule</code> table reference
|
||||||
|
*/
|
||||||
|
public MockDataRule(Name alias) {
|
||||||
|
this(alias, MOCK_DATA_RULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a <code>databasir.mock_data_rule</code> table reference
|
||||||
|
*/
|
||||||
|
public MockDataRule() {
|
||||||
|
this(DSL.name("mock_data_rule"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <O extends Record> MockDataRule(Table<O> child, ForeignKey<O, MockDataRuleRecord> key) {
|
||||||
|
super(child, key, MOCK_DATA_RULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Schema getSchema() {
|
||||||
|
return aliased() ? null : Databasir.DATABASIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identity<MockDataRuleRecord, Integer> getIdentity() {
|
||||||
|
return (Identity<MockDataRuleRecord, Integer>) super.getIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UniqueKey<MockDataRuleRecord> getPrimaryKey() {
|
||||||
|
return Keys.KEY_MOCK_DATA_RULE_PRIMARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UniqueKey<MockDataRuleRecord>> getUniqueKeys() {
|
||||||
|
return Arrays.asList(Keys.KEY_MOCK_DATA_RULE_UK_PROJECT_ID_TABLE_NAME_COLUMN_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRule as(String alias) {
|
||||||
|
return new MockDataRule(DSL.name(alias), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRule as(Name alias) {
|
||||||
|
return new MockDataRule(alias, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename this table
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MockDataRule rename(String name) {
|
||||||
|
return new MockDataRule(DSL.name(name), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename this table
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MockDataRule rename(Name name) {
|
||||||
|
return new MockDataRule(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Row10 type methods
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Row10<Integer, Integer, String, String, String, String, MockDataType, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||||
|
return (Row10) super.fieldsRow();
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ import org.jooq.Identity;
|
||||||
import org.jooq.Index;
|
import org.jooq.Index;
|
||||||
import org.jooq.Name;
|
import org.jooq.Name;
|
||||||
import org.jooq.Record;
|
import org.jooq.Record;
|
||||||
import org.jooq.Row13;
|
import org.jooq.Row14;
|
||||||
import org.jooq.Schema;
|
import org.jooq.Schema;
|
||||||
import org.jooq.Table;
|
import org.jooq.Table;
|
||||||
import org.jooq.TableField;
|
import org.jooq.TableField;
|
||||||
|
@ -78,6 +78,11 @@ public class TableColumnDocument extends TableImpl<TableColumnDocumentRecord> {
|
||||||
*/
|
*/
|
||||||
public final TableField<TableColumnDocumentRecord, String> TYPE = createField(DSL.name("type"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
public final TableField<TableColumnDocumentRecord, String> TYPE = createField(DSL.name("type"), SQLDataType.VARCHAR(255).nullable(false), this, "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The column <code>databasir.table_column_document.data_type</code>.
|
||||||
|
*/
|
||||||
|
public final TableField<TableColumnDocumentRecord, Integer> DATA_TYPE = createField(DSL.name("data_type"), SQLDataType.INTEGER.nullable(false).defaultValue(DSL.inline("99999", SQLDataType.INTEGER)), this, "");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column <code>databasir.table_column_document.comment</code>.
|
* The column <code>databasir.table_column_document.comment</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -202,11 +207,11 @@ public class TableColumnDocument extends TableImpl<TableColumnDocumentRecord> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Row13 type methods
|
// Row14 type methods
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
public Row14<Integer, Integer, Integer, String, String, Integer, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
||||||
return (Row13) super.fieldsRow();
|
return (Row14) super.fieldsRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,229 @@
|
||||||
|
/*
|
||||||
|
* This file is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
package com.databasir.dao.tables.pojos;
|
||||||
|
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
|
public class MockDataRulePojo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private Integer projectId;
|
||||||
|
private String tableName;
|
||||||
|
private String columnName;
|
||||||
|
private String dependentTableName;
|
||||||
|
private String dependentColumnName;
|
||||||
|
private MockDataType mockDataType;
|
||||||
|
private String mockDataScript;
|
||||||
|
private LocalDateTime updateAt;
|
||||||
|
private LocalDateTime createAt;
|
||||||
|
|
||||||
|
public MockDataRulePojo() {}
|
||||||
|
|
||||||
|
public MockDataRulePojo(MockDataRulePojo value) {
|
||||||
|
this.id = value.id;
|
||||||
|
this.projectId = value.projectId;
|
||||||
|
this.tableName = value.tableName;
|
||||||
|
this.columnName = value.columnName;
|
||||||
|
this.dependentTableName = value.dependentTableName;
|
||||||
|
this.dependentColumnName = value.dependentColumnName;
|
||||||
|
this.mockDataType = value.mockDataType;
|
||||||
|
this.mockDataScript = value.mockDataScript;
|
||||||
|
this.updateAt = value.updateAt;
|
||||||
|
this.createAt = value.createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MockDataRulePojo(
|
||||||
|
Integer id,
|
||||||
|
Integer projectId,
|
||||||
|
String tableName,
|
||||||
|
String columnName,
|
||||||
|
String dependentTableName,
|
||||||
|
String dependentColumnName,
|
||||||
|
MockDataType mockDataType,
|
||||||
|
String mockDataScript,
|
||||||
|
LocalDateTime updateAt,
|
||||||
|
LocalDateTime createAt
|
||||||
|
) {
|
||||||
|
this.id = id;
|
||||||
|
this.projectId = projectId;
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.columnName = columnName;
|
||||||
|
this.dependentTableName = dependentTableName;
|
||||||
|
this.dependentColumnName = dependentColumnName;
|
||||||
|
this.mockDataType = mockDataType;
|
||||||
|
this.mockDataScript = mockDataScript;
|
||||||
|
this.updateAt = updateAt;
|
||||||
|
this.createAt = createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.id</code>.
|
||||||
|
*/
|
||||||
|
public Integer getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.id</code>.
|
||||||
|
*/
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.project_id</code>.
|
||||||
|
*/
|
||||||
|
public Integer getProjectId() {
|
||||||
|
return this.projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.project_id</code>.
|
||||||
|
*/
|
||||||
|
public void setProjectId(Integer projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.table_name</code>.
|
||||||
|
*/
|
||||||
|
public String getTableName() {
|
||||||
|
return this.tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.table_name</code>.
|
||||||
|
*/
|
||||||
|
public void setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.column_name</code>.
|
||||||
|
*/
|
||||||
|
public String getColumnName() {
|
||||||
|
return this.columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.column_name</code>.
|
||||||
|
*/
|
||||||
|
public void setColumnName(String columnName) {
|
||||||
|
this.columnName = columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.dependent_table_name</code>.
|
||||||
|
*/
|
||||||
|
public String getDependentTableName() {
|
||||||
|
return this.dependentTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.dependent_table_name</code>.
|
||||||
|
*/
|
||||||
|
public void setDependentTableName(String dependentTableName) {
|
||||||
|
this.dependentTableName = dependentTableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.dependent_column_name</code>.
|
||||||
|
*/
|
||||||
|
public String getDependentColumnName() {
|
||||||
|
return this.dependentColumnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.dependent_column_name</code>.
|
||||||
|
*/
|
||||||
|
public void setDependentColumnName(String dependentColumnName) {
|
||||||
|
this.dependentColumnName = dependentColumnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.mock_data_type</code>.
|
||||||
|
*/
|
||||||
|
public MockDataType getMockDataType() {
|
||||||
|
return this.mockDataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.mock_data_type</code>.
|
||||||
|
*/
|
||||||
|
public void setMockDataType(MockDataType mockDataType) {
|
||||||
|
this.mockDataType = mockDataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.mock_data_script</code>.
|
||||||
|
*/
|
||||||
|
public String getMockDataScript() {
|
||||||
|
return this.mockDataScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.mock_data_script</code>.
|
||||||
|
*/
|
||||||
|
public void setMockDataScript(String mockDataScript) {
|
||||||
|
this.mockDataScript = mockDataScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.update_at</code>.
|
||||||
|
*/
|
||||||
|
public LocalDateTime getUpdateAt() {
|
||||||
|
return this.updateAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.update_at</code>.
|
||||||
|
*/
|
||||||
|
public void setUpdateAt(LocalDateTime updateAt) {
|
||||||
|
this.updateAt = updateAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.create_at</code>.
|
||||||
|
*/
|
||||||
|
public LocalDateTime getCreateAt() {
|
||||||
|
return this.createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.create_at</code>.
|
||||||
|
*/
|
||||||
|
public void setCreateAt(LocalDateTime createAt) {
|
||||||
|
this.createAt = createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder("MockDataRulePojo (");
|
||||||
|
|
||||||
|
sb.append(id);
|
||||||
|
sb.append(", ").append(projectId);
|
||||||
|
sb.append(", ").append(tableName);
|
||||||
|
sb.append(", ").append(columnName);
|
||||||
|
sb.append(", ").append(dependentTableName);
|
||||||
|
sb.append(", ").append(dependentColumnName);
|
||||||
|
sb.append(", ").append(mockDataType);
|
||||||
|
sb.append(", ").append(mockDataScript);
|
||||||
|
sb.append(", ").append(updateAt);
|
||||||
|
sb.append(", ").append(createAt);
|
||||||
|
|
||||||
|
sb.append(")");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
private Integer databaseDocumentId;
|
private Integer databaseDocumentId;
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
|
private Integer dataType;
|
||||||
private String comment;
|
private String comment;
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
private Integer size;
|
private Integer size;
|
||||||
|
@ -38,6 +39,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
this.databaseDocumentId = value.databaseDocumentId;
|
this.databaseDocumentId = value.databaseDocumentId;
|
||||||
this.name = value.name;
|
this.name = value.name;
|
||||||
this.type = value.type;
|
this.type = value.type;
|
||||||
|
this.dataType = value.dataType;
|
||||||
this.comment = value.comment;
|
this.comment = value.comment;
|
||||||
this.defaultValue = value.defaultValue;
|
this.defaultValue = value.defaultValue;
|
||||||
this.size = value.size;
|
this.size = value.size;
|
||||||
|
@ -54,6 +56,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
Integer databaseDocumentId,
|
Integer databaseDocumentId,
|
||||||
String name,
|
String name,
|
||||||
String type,
|
String type,
|
||||||
|
Integer dataType,
|
||||||
String comment,
|
String comment,
|
||||||
String defaultValue,
|
String defaultValue,
|
||||||
Integer size,
|
Integer size,
|
||||||
|
@ -68,6 +71,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
this.databaseDocumentId = databaseDocumentId;
|
this.databaseDocumentId = databaseDocumentId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.dataType = dataType;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
@ -152,6 +156,20 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.table_column_document.data_type</code>.
|
||||||
|
*/
|
||||||
|
public Integer getDataType() {
|
||||||
|
return this.dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.table_column_document.data_type</code>.
|
||||||
|
*/
|
||||||
|
public void setDataType(Integer dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.comment</code>.
|
* Getter for <code>databasir.table_column_document.comment</code>.
|
||||||
*/
|
*/
|
||||||
|
@ -277,6 +295,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
||||||
sb.append(", ").append(databaseDocumentId);
|
sb.append(", ").append(databaseDocumentId);
|
||||||
sb.append(", ").append(name);
|
sb.append(", ").append(name);
|
||||||
sb.append(", ").append(type);
|
sb.append(", ").append(type);
|
||||||
|
sb.append(", ").append(dataType);
|
||||||
sb.append(", ").append(comment);
|
sb.append(", ").append(comment);
|
||||||
sb.append(", ").append(defaultValue);
|
sb.append(", ").append(defaultValue);
|
||||||
sb.append(", ").append(size);
|
sb.append(", ").append(size);
|
||||||
|
|
|
@ -0,0 +1,464 @@
|
||||||
|
/*
|
||||||
|
* This file is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
package com.databasir.dao.tables.records;
|
||||||
|
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import com.databasir.dao.tables.MockDataRule;
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.jooq.Field;
|
||||||
|
import org.jooq.Record1;
|
||||||
|
import org.jooq.Record10;
|
||||||
|
import org.jooq.Row10;
|
||||||
|
import org.jooq.impl.UpdatableRecordImpl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is generated by jOOQ.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
|
public class MockDataRuleRecord extends UpdatableRecordImpl<MockDataRuleRecord> implements Record10<Integer, Integer, String, String, String, String, MockDataType, String, LocalDateTime, LocalDateTime> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.id</code>.
|
||||||
|
*/
|
||||||
|
public void setId(Integer value) {
|
||||||
|
set(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.id</code>.
|
||||||
|
*/
|
||||||
|
public Integer getId() {
|
||||||
|
return (Integer) get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.project_id</code>.
|
||||||
|
*/
|
||||||
|
public void setProjectId(Integer value) {
|
||||||
|
set(1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.project_id</code>.
|
||||||
|
*/
|
||||||
|
public Integer getProjectId() {
|
||||||
|
return (Integer) get(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.table_name</code>.
|
||||||
|
*/
|
||||||
|
public void setTableName(String value) {
|
||||||
|
set(2, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.table_name</code>.
|
||||||
|
*/
|
||||||
|
public String getTableName() {
|
||||||
|
return (String) get(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.column_name</code>.
|
||||||
|
*/
|
||||||
|
public void setColumnName(String value) {
|
||||||
|
set(3, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.column_name</code>.
|
||||||
|
*/
|
||||||
|
public String getColumnName() {
|
||||||
|
return (String) get(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.dependent_table_name</code>.
|
||||||
|
*/
|
||||||
|
public void setDependentTableName(String value) {
|
||||||
|
set(4, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.dependent_table_name</code>.
|
||||||
|
*/
|
||||||
|
public String getDependentTableName() {
|
||||||
|
return (String) get(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.dependent_column_name</code>.
|
||||||
|
*/
|
||||||
|
public void setDependentColumnName(String value) {
|
||||||
|
set(5, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.dependent_column_name</code>.
|
||||||
|
*/
|
||||||
|
public String getDependentColumnName() {
|
||||||
|
return (String) get(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.mock_data_type</code>.
|
||||||
|
*/
|
||||||
|
public void setMockDataType(MockDataType value) {
|
||||||
|
set(6, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.mock_data_type</code>.
|
||||||
|
*/
|
||||||
|
public MockDataType getMockDataType() {
|
||||||
|
return (MockDataType) get(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.mock_data_script</code>.
|
||||||
|
*/
|
||||||
|
public void setMockDataScript(String value) {
|
||||||
|
set(7, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.mock_data_script</code>.
|
||||||
|
*/
|
||||||
|
public String getMockDataScript() {
|
||||||
|
return (String) get(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.update_at</code>.
|
||||||
|
*/
|
||||||
|
public void setUpdateAt(LocalDateTime value) {
|
||||||
|
set(8, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.update_at</code>.
|
||||||
|
*/
|
||||||
|
public LocalDateTime getUpdateAt() {
|
||||||
|
return (LocalDateTime) get(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.mock_data_rule.create_at</code>.
|
||||||
|
*/
|
||||||
|
public void setCreateAt(LocalDateTime value) {
|
||||||
|
set(9, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.mock_data_rule.create_at</code>.
|
||||||
|
*/
|
||||||
|
public LocalDateTime getCreateAt() {
|
||||||
|
return (LocalDateTime) get(9);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Primary key information
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Record1<Integer> key() {
|
||||||
|
return (Record1) super.key();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Record10 type implementation
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Row10<Integer, Integer, String, String, String, String, MockDataType, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||||
|
return (Row10) super.fieldsRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Row10<Integer, Integer, String, String, String, String, MockDataType, String, LocalDateTime, LocalDateTime> valuesRow() {
|
||||||
|
return (Row10) super.valuesRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<Integer> field1() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<Integer> field2() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.PROJECT_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field3() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.TABLE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field4() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.COLUMN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field5() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.DEPENDENT_TABLE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field6() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.DEPENDENT_COLUMN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<MockDataType> field7() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.MOCK_DATA_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field8() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.MOCK_DATA_SCRIPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<LocalDateTime> field9() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.UPDATE_AT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<LocalDateTime> field10() {
|
||||||
|
return MockDataRule.MOCK_DATA_RULE.CREATE_AT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer component1() {
|
||||||
|
return getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer component2() {
|
||||||
|
return getProjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component3() {
|
||||||
|
return getTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component4() {
|
||||||
|
return getColumnName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component5() {
|
||||||
|
return getDependentTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component6() {
|
||||||
|
return getDependentColumnName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataType component7() {
|
||||||
|
return getMockDataType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component8() {
|
||||||
|
return getMockDataScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime component9() {
|
||||||
|
return getUpdateAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime component10() {
|
||||||
|
return getCreateAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer value1() {
|
||||||
|
return getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer value2() {
|
||||||
|
return getProjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value3() {
|
||||||
|
return getTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value4() {
|
||||||
|
return getColumnName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value5() {
|
||||||
|
return getDependentTableName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value6() {
|
||||||
|
return getDependentColumnName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataType value7() {
|
||||||
|
return getMockDataType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value8() {
|
||||||
|
return getMockDataScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime value9() {
|
||||||
|
return getUpdateAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime value10() {
|
||||||
|
return getCreateAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value1(Integer value) {
|
||||||
|
setId(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value2(Integer value) {
|
||||||
|
setProjectId(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value3(String value) {
|
||||||
|
setTableName(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value4(String value) {
|
||||||
|
setColumnName(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value5(String value) {
|
||||||
|
setDependentTableName(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value6(String value) {
|
||||||
|
setDependentColumnName(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value7(MockDataType value) {
|
||||||
|
setMockDataType(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value8(String value) {
|
||||||
|
setMockDataScript(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value9(LocalDateTime value) {
|
||||||
|
setUpdateAt(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord value10(LocalDateTime value) {
|
||||||
|
setCreateAt(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MockDataRuleRecord values(Integer value1, Integer value2, String value3, String value4, String value5, String value6, MockDataType value7, String value8, LocalDateTime value9, LocalDateTime value10) {
|
||||||
|
value1(value1);
|
||||||
|
value2(value2);
|
||||||
|
value3(value3);
|
||||||
|
value4(value4);
|
||||||
|
value5(value5);
|
||||||
|
value6(value6);
|
||||||
|
value7(value7);
|
||||||
|
value8(value8);
|
||||||
|
value9(value9);
|
||||||
|
value10(value10);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Constructors
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a detached MockDataRuleRecord
|
||||||
|
*/
|
||||||
|
public MockDataRuleRecord() {
|
||||||
|
super(MockDataRule.MOCK_DATA_RULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a detached, initialised MockDataRuleRecord
|
||||||
|
*/
|
||||||
|
public MockDataRuleRecord(Integer id, Integer projectId, String tableName, String columnName, String dependentTableName, String dependentColumnName, MockDataType mockDataType, String mockDataScript, LocalDateTime updateAt, LocalDateTime createAt) {
|
||||||
|
super(MockDataRule.MOCK_DATA_RULE);
|
||||||
|
|
||||||
|
setId(id);
|
||||||
|
setProjectId(projectId);
|
||||||
|
setTableName(tableName);
|
||||||
|
setColumnName(columnName);
|
||||||
|
setDependentTableName(dependentTableName);
|
||||||
|
setDependentColumnName(dependentColumnName);
|
||||||
|
setMockDataType(mockDataType);
|
||||||
|
setMockDataScript(mockDataScript);
|
||||||
|
setUpdateAt(updateAt);
|
||||||
|
setCreateAt(createAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a detached, initialised MockDataRuleRecord
|
||||||
|
*/
|
||||||
|
public MockDataRuleRecord(MockDataRulePojo value) {
|
||||||
|
super(MockDataRule.MOCK_DATA_RULE);
|
||||||
|
|
||||||
|
if (value != null) {
|
||||||
|
setId(value.getId());
|
||||||
|
setProjectId(value.getProjectId());
|
||||||
|
setTableName(value.getTableName());
|
||||||
|
setColumnName(value.getColumnName());
|
||||||
|
setDependentTableName(value.getDependentTableName());
|
||||||
|
setDependentColumnName(value.getDependentColumnName());
|
||||||
|
setMockDataType(value.getMockDataType());
|
||||||
|
setMockDataScript(value.getMockDataScript());
|
||||||
|
setUpdateAt(value.getUpdateAt());
|
||||||
|
setCreateAt(value.getCreateAt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,8 +11,8 @@ import java.time.LocalDateTime;
|
||||||
|
|
||||||
import org.jooq.Field;
|
import org.jooq.Field;
|
||||||
import org.jooq.Record1;
|
import org.jooq.Record1;
|
||||||
import org.jooq.Record13;
|
import org.jooq.Record14;
|
||||||
import org.jooq.Row13;
|
import org.jooq.Row14;
|
||||||
import org.jooq.impl.UpdatableRecordImpl;
|
import org.jooq.impl.UpdatableRecordImpl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
|
||||||
* This class is generated by jOOQ.
|
* This class is generated by jOOQ.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||||
public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDocumentRecord> implements Record13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> {
|
public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDocumentRecord> implements Record14<Integer, Integer, Integer, String, String, Integer, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -98,74 +98,88 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
return (String) get(4);
|
return (String) get(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for <code>databasir.table_column_document.data_type</code>.
|
||||||
|
*/
|
||||||
|
public void setDataType(Integer value) {
|
||||||
|
set(5, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for <code>databasir.table_column_document.data_type</code>.
|
||||||
|
*/
|
||||||
|
public Integer getDataType() {
|
||||||
|
return (Integer) get(5);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.comment</code>.
|
* Setter for <code>databasir.table_column_document.comment</code>.
|
||||||
*/
|
*/
|
||||||
public void setComment(String value) {
|
public void setComment(String value) {
|
||||||
set(5, value);
|
set(6, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.comment</code>.
|
* Getter for <code>databasir.table_column_document.comment</code>.
|
||||||
*/
|
*/
|
||||||
public String getComment() {
|
public String getComment() {
|
||||||
return (String) get(5);
|
return (String) get(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.default_value</code>.
|
* Setter for <code>databasir.table_column_document.default_value</code>.
|
||||||
*/
|
*/
|
||||||
public void setDefaultValue(String value) {
|
public void setDefaultValue(String value) {
|
||||||
set(6, value);
|
set(7, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.default_value</code>.
|
* Getter for <code>databasir.table_column_document.default_value</code>.
|
||||||
*/
|
*/
|
||||||
public String getDefaultValue() {
|
public String getDefaultValue() {
|
||||||
return (String) get(6);
|
return (String) get(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.size</code>.
|
* Setter for <code>databasir.table_column_document.size</code>.
|
||||||
*/
|
*/
|
||||||
public void setSize(Integer value) {
|
public void setSize(Integer value) {
|
||||||
set(7, value);
|
set(8, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.size</code>.
|
* Getter for <code>databasir.table_column_document.size</code>.
|
||||||
*/
|
*/
|
||||||
public Integer getSize() {
|
public Integer getSize() {
|
||||||
return (Integer) get(7);
|
return (Integer) get(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.decimal_digits</code>.
|
* Setter for <code>databasir.table_column_document.decimal_digits</code>.
|
||||||
*/
|
*/
|
||||||
public void setDecimalDigits(Integer value) {
|
public void setDecimalDigits(Integer value) {
|
||||||
set(8, value);
|
set(9, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.decimal_digits</code>.
|
* Getter for <code>databasir.table_column_document.decimal_digits</code>.
|
||||||
*/
|
*/
|
||||||
public Integer getDecimalDigits() {
|
public Integer getDecimalDigits() {
|
||||||
return (Integer) get(8);
|
return (Integer) get(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.is_primary_key</code>.
|
* Setter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||||
*/
|
*/
|
||||||
public void setIsPrimaryKey(Boolean value) {
|
public void setIsPrimaryKey(Boolean value) {
|
||||||
set(9, value);
|
set(10, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.is_primary_key</code>.
|
* Getter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||||
*/
|
*/
|
||||||
public Boolean getIsPrimaryKey() {
|
public Boolean getIsPrimaryKey() {
|
||||||
return (Boolean) get(9);
|
return (Boolean) get(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,7 +187,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
* NO, UNKNOWN
|
* NO, UNKNOWN
|
||||||
*/
|
*/
|
||||||
public void setNullable(String value) {
|
public void setNullable(String value) {
|
||||||
set(10, value);
|
set(11, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +195,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
* NO, UNKNOWN
|
* NO, UNKNOWN
|
||||||
*/
|
*/
|
||||||
public String getNullable() {
|
public String getNullable() {
|
||||||
return (String) get(10);
|
return (String) get(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -189,7 +203,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
* YES, NO, UNKNOWN
|
* YES, NO, UNKNOWN
|
||||||
*/
|
*/
|
||||||
public void setAutoIncrement(String value) {
|
public void setAutoIncrement(String value) {
|
||||||
set(11, value);
|
set(12, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,21 +211,21 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
* YES, NO, UNKNOWN
|
* YES, NO, UNKNOWN
|
||||||
*/
|
*/
|
||||||
public String getAutoIncrement() {
|
public String getAutoIncrement() {
|
||||||
return (String) get(11);
|
return (String) get(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for <code>databasir.table_column_document.create_at</code>.
|
* Setter for <code>databasir.table_column_document.create_at</code>.
|
||||||
*/
|
*/
|
||||||
public void setCreateAt(LocalDateTime value) {
|
public void setCreateAt(LocalDateTime value) {
|
||||||
set(12, value);
|
set(13, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for <code>databasir.table_column_document.create_at</code>.
|
* Getter for <code>databasir.table_column_document.create_at</code>.
|
||||||
*/
|
*/
|
||||||
public LocalDateTime getCreateAt() {
|
public LocalDateTime getCreateAt() {
|
||||||
return (LocalDateTime) get(12);
|
return (LocalDateTime) get(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
@ -224,17 +238,17 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Record13 type implementation
|
// Record14 type implementation
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
public Row14<Integer, Integer, Integer, String, String, Integer, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
||||||
return (Row13) super.fieldsRow();
|
return (Row14) super.fieldsRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> valuesRow() {
|
public Row14<Integer, Integer, Integer, String, String, Integer, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> valuesRow() {
|
||||||
return (Row13) super.valuesRow();
|
return (Row14) super.valuesRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -263,42 +277,47 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field6() {
|
public Field<Integer> field6() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.COMMENT;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DATA_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field7() {
|
public Field<String> field7() {
|
||||||
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Field<String> field8() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DEFAULT_VALUE;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DEFAULT_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<Integer> field8() {
|
public Field<Integer> field9() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.SIZE;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<Integer> field9() {
|
public Field<Integer> field10() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DECIMAL_DIGITS;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.DECIMAL_DIGITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<Boolean> field10() {
|
public Field<Boolean> field11() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.IS_PRIMARY_KEY;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.IS_PRIMARY_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field11() {
|
public Field<String> field12() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NULLABLE;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NULLABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<String> field12() {
|
public Field<String> field13() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.AUTO_INCREMENT;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.AUTO_INCREMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Field<LocalDateTime> field13() {
|
public Field<LocalDateTime> field14() {
|
||||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.CREATE_AT;
|
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.CREATE_AT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,42 +347,47 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component6() {
|
public Integer component6() {
|
||||||
return getComment();
|
return getDataType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component7() {
|
public String component7() {
|
||||||
|
return getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String component8() {
|
||||||
return getDefaultValue();
|
return getDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer component8() {
|
public Integer component9() {
|
||||||
return getSize();
|
return getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer component9() {
|
public Integer component10() {
|
||||||
return getDecimalDigits();
|
return getDecimalDigits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean component10() {
|
public Boolean component11() {
|
||||||
return getIsPrimaryKey();
|
return getIsPrimaryKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component11() {
|
public String component12() {
|
||||||
return getNullable();
|
return getNullable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String component12() {
|
public String component13() {
|
||||||
return getAutoIncrement();
|
return getAutoIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime component13() {
|
public LocalDateTime component14() {
|
||||||
return getCreateAt();
|
return getCreateAt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,42 +417,47 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value6() {
|
public Integer value6() {
|
||||||
return getComment();
|
return getDataType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value7() {
|
public String value7() {
|
||||||
|
return getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String value8() {
|
||||||
return getDefaultValue();
|
return getDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer value8() {
|
public Integer value9() {
|
||||||
return getSize();
|
return getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer value9() {
|
public Integer value10() {
|
||||||
return getDecimalDigits();
|
return getDecimalDigits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean value10() {
|
public Boolean value11() {
|
||||||
return getIsPrimaryKey();
|
return getIsPrimaryKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value11() {
|
public String value12() {
|
||||||
return getNullable();
|
return getNullable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String value12() {
|
public String value13() {
|
||||||
return getAutoIncrement();
|
return getAutoIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime value13() {
|
public LocalDateTime value14() {
|
||||||
return getCreateAt();
|
return getCreateAt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,55 +492,61 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value6(String value) {
|
public TableColumnDocumentRecord value6(Integer value) {
|
||||||
setComment(value);
|
setDataType(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value7(String value) {
|
public TableColumnDocumentRecord value7(String value) {
|
||||||
|
setComment(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableColumnDocumentRecord value8(String value) {
|
||||||
setDefaultValue(value);
|
setDefaultValue(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value8(Integer value) {
|
public TableColumnDocumentRecord value9(Integer value) {
|
||||||
setSize(value);
|
setSize(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value9(Integer value) {
|
public TableColumnDocumentRecord value10(Integer value) {
|
||||||
setDecimalDigits(value);
|
setDecimalDigits(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value10(Boolean value) {
|
public TableColumnDocumentRecord value11(Boolean value) {
|
||||||
setIsPrimaryKey(value);
|
setIsPrimaryKey(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value11(String value) {
|
public TableColumnDocumentRecord value12(String value) {
|
||||||
setNullable(value);
|
setNullable(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value12(String value) {
|
public TableColumnDocumentRecord value13(String value) {
|
||||||
setAutoIncrement(value);
|
setAutoIncrement(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord value13(LocalDateTime value) {
|
public TableColumnDocumentRecord value14(LocalDateTime value) {
|
||||||
setCreateAt(value);
|
setCreateAt(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableColumnDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, Integer value8, Integer value9, Boolean value10, String value11, String value12, LocalDateTime value13) {
|
public TableColumnDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, Integer value6, String value7, String value8, Integer value9, Integer value10, Boolean value11, String value12, String value13, LocalDateTime value14) {
|
||||||
value1(value1);
|
value1(value1);
|
||||||
value2(value2);
|
value2(value2);
|
||||||
value3(value3);
|
value3(value3);
|
||||||
|
@ -525,6 +560,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
value11(value11);
|
value11(value11);
|
||||||
value12(value12);
|
value12(value12);
|
||||||
value13(value13);
|
value13(value13);
|
||||||
|
value14(value14);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,7 +578,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
/**
|
/**
|
||||||
* Create a detached, initialised TableColumnDocumentRecord
|
* Create a detached, initialised TableColumnDocumentRecord
|
||||||
*/
|
*/
|
||||||
public TableColumnDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, String type, String comment, String defaultValue, Integer size, Integer decimalDigits, Boolean isPrimaryKey, String nullable, String autoIncrement, LocalDateTime createAt) {
|
public TableColumnDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, String type, Integer dataType, String comment, String defaultValue, Integer size, Integer decimalDigits, Boolean isPrimaryKey, String nullable, String autoIncrement, LocalDateTime createAt) {
|
||||||
super(TableColumnDocument.TABLE_COLUMN_DOCUMENT);
|
super(TableColumnDocument.TABLE_COLUMN_DOCUMENT);
|
||||||
|
|
||||||
setId(id);
|
setId(id);
|
||||||
|
@ -550,6 +586,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
setDatabaseDocumentId(databaseDocumentId);
|
setDatabaseDocumentId(databaseDocumentId);
|
||||||
setName(name);
|
setName(name);
|
||||||
setType(type);
|
setType(type);
|
||||||
|
setDataType(dataType);
|
||||||
setComment(comment);
|
setComment(comment);
|
||||||
setDefaultValue(defaultValue);
|
setDefaultValue(defaultValue);
|
||||||
setSize(size);
|
setSize(size);
|
||||||
|
@ -572,6 +609,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
||||||
setDatabaseDocumentId(value.getDatabaseDocumentId());
|
setDatabaseDocumentId(value.getDatabaseDocumentId());
|
||||||
setName(value.getName());
|
setName(value.getName());
|
||||||
setType(value.getType());
|
setType(value.getType());
|
||||||
|
setDataType(value.getDataType());
|
||||||
setComment(value.getComment());
|
setComment(value.getComment());
|
||||||
setDefaultValue(value.getDefaultValue());
|
setDefaultValue(value.getDefaultValue());
|
||||||
setSize(value.getSize());
|
setSize(value.getSize());
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.databasir.dao.converter;
|
||||||
|
|
||||||
|
import com.databasir.dao.enums.MockDataType;
|
||||||
|
import org.jooq.impl.EnumConverter;
|
||||||
|
|
||||||
|
public class MockDataTypeConverter extends EnumConverter<String, MockDataType> {
|
||||||
|
|
||||||
|
public MockDataTypeConverter() {
|
||||||
|
super(String.class, MockDataType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.databasir.dao.enums;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum MockDataType {
|
||||||
|
|
||||||
|
// java faker supported type
|
||||||
|
PHONE,
|
||||||
|
EMAIL,
|
||||||
|
FULL_NAME,
|
||||||
|
FULL_ADDRESS,
|
||||||
|
AVATAR_URL,
|
||||||
|
UUID,
|
||||||
|
|
||||||
|
// databasir custom type
|
||||||
|
SCRIPT,
|
||||||
|
CONSTANT,
|
||||||
|
REF,
|
||||||
|
AUTO,
|
||||||
|
;
|
||||||
|
|
||||||
|
public static List<MockDataType> fakerTypes() {
|
||||||
|
return List.of(PHONE, EMAIL, FULL_NAME, FULL_ADDRESS, AVATAR_URL, UUID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.databasir.dao.impl;
|
||||||
|
|
||||||
|
import com.databasir.dao.tables.pojos.MockDataRulePojo;
|
||||||
|
import com.databasir.dao.tables.records.MockDataRuleRecord;
|
||||||
|
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.MOCK_DATA_RULE;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class MockDataRuleDao extends BaseDao<MockDataRulePojo> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Getter
|
||||||
|
private DSLContext dslContext;
|
||||||
|
|
||||||
|
public MockDataRuleDao() {
|
||||||
|
super(MOCK_DATA_RULE, MockDataRulePojo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MockDataRulePojo> selectByProjectId(Integer projectId) {
|
||||||
|
return this.getDslContext()
|
||||||
|
.selectFrom(MOCK_DATA_RULE)
|
||||||
|
.where(MOCK_DATA_RULE.PROJECT_ID.eq(projectId))
|
||||||
|
.fetchInto(MockDataRulePojo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MockDataRulePojo> selectByProjectIdAndTableName(Integer projectId, String tableName) {
|
||||||
|
return this.getDslContext()
|
||||||
|
.selectFrom(MOCK_DATA_RULE)
|
||||||
|
.where(MOCK_DATA_RULE.PROJECT_ID.eq(projectId)
|
||||||
|
.and(MOCK_DATA_RULE.TABLE_NAME.eq(tableName)))
|
||||||
|
.fetchInto(MockDataRulePojo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void batchSave(Collection<MockDataRulePojo> data) {
|
||||||
|
if (data == null || data.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<InsertReturningStep<MockDataRuleRecord>> query = data.stream()
|
||||||
|
.map(pojo -> getDslContext()
|
||||||
|
.insertInto(MOCK_DATA_RULE)
|
||||||
|
.set(getDslContext().newRecord(MOCK_DATA_RULE, pojo))
|
||||||
|
.onDuplicateKeyUpdate()
|
||||||
|
.set(MOCK_DATA_RULE.MOCK_DATA_TYPE, pojo.getMockDataType())
|
||||||
|
.set(MOCK_DATA_RULE.MOCK_DATA_SCRIPT, pojo.getMockDataScript())
|
||||||
|
.set(MOCK_DATA_RULE.DEPENDENT_COLUMN_NAME, pojo.getDependentColumnName())
|
||||||
|
.set(MOCK_DATA_RULE.DEPENDENT_TABLE_NAME, pojo.getDependentTableName())
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
getDslContext().batch(query).execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -40,4 +40,17 @@ public class TableColumnDocumentDao extends BaseDao<TableColumnDocumentPojo> {
|
||||||
.and(TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
|
.and(TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
|
||||||
.fetchInto(TableColumnDocumentPojo.class);
|
.fetchInto(TableColumnDocumentPojo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TableColumnDocumentPojo> selectByTableDocumentId(Integer tableDocumentId) {
|
||||||
|
return getDslContext()
|
||||||
|
.selectFrom(TABLE_COLUMN_DOCUMENT)
|
||||||
|
.where(TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID.eq(tableDocumentId))
|
||||||
|
.fetchInto(TableColumnDocumentPojo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exists(Integer tableDocumentId, String columnName) {
|
||||||
|
return getDslContext()
|
||||||
|
.fetchExists(TABLE_COLUMN_DOCUMENT, TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID.eq(tableDocumentId)
|
||||||
|
.and(TABLE_COLUMN_DOCUMENT.NAME.eq(columnName)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.databasir.dao.impl;
|
package com.databasir.dao.impl;
|
||||||
|
|
||||||
|
import com.databasir.dao.tables.pojos.TableColumnDocumentPojo;
|
||||||
import com.databasir.dao.tables.pojos.TableDocumentPojo;
|
import com.databasir.dao.tables.pojos.TableDocumentPojo;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
|
@ -8,6 +9,7 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.databasir.dao.Tables.TABLE_DOCUMENT;
|
import static com.databasir.dao.Tables.TABLE_DOCUMENT;
|
||||||
|
|
||||||
|
@ -29,12 +31,6 @@ public class TableDocumentDao extends BaseDao<TableDocumentPojo> {
|
||||||
.fetchInto(TableDocumentPojo.class);
|
.fetchInto(TableDocumentPojo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteByDatabaseDocumentId(Integer schemaDocumentId) {
|
|
||||||
getDslContext()
|
|
||||||
.deleteFrom(TABLE_DOCUMENT).where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId))
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TableDocumentPojo> selectByDatabaseDocumentIdAndIdIn(Integer databaseDocumentId,
|
public List<TableDocumentPojo> selectByDatabaseDocumentIdAndIdIn(Integer databaseDocumentId,
|
||||||
List<Integer> idList) {
|
List<Integer> idList) {
|
||||||
if (idList == null || idList.isEmpty()) {
|
if (idList == null || idList.isEmpty()) {
|
||||||
|
@ -46,4 +42,22 @@ public class TableDocumentDao extends BaseDao<TableDocumentPojo> {
|
||||||
.and(TABLE_DOCUMENT.ID.in(idList)))
|
.and(TABLE_DOCUMENT.ID.in(idList)))
|
||||||
.fetchInto(TableDocumentPojo.class);
|
.fetchInto(TableDocumentPojo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<TableColumnDocumentPojo> selectByDatabaseDocumentIdAndTableName(Integer databaseDocumentId,
|
||||||
|
String tableName) {
|
||||||
|
return getDslContext()
|
||||||
|
.select(TABLE_DOCUMENT.fields()).from(TABLE_DOCUMENT)
|
||||||
|
.where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(databaseDocumentId)
|
||||||
|
.and(TABLE_DOCUMENT.NAME.eq(tableName)))
|
||||||
|
.fetchOptionalInto(TableColumnDocumentPojo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<TableDocumentPojo> selectByDatabaseDocumentIdAndId(Integer databaseDocumentId,
|
||||||
|
Integer id) {
|
||||||
|
return getDslContext()
|
||||||
|
.selectFrom(TABLE_DOCUMENT)
|
||||||
|
.where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(databaseDocumentId)
|
||||||
|
.and(TABLE_DOCUMENT.ID.eq(id)))
|
||||||
|
.fetchOptionalInto(TableDocumentPojo.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS mock_data_rule
|
||||||
|
(
|
||||||
|
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`project_id` INT NOT NULL,
|
||||||
|
`table_name` VARCHAR(255) NOT NULL,
|
||||||
|
`column_name` VARCHAR(255) NOT NULL,
|
||||||
|
`dependent_table_name` VARCHAR(255) DEFAULT NULL,
|
||||||
|
`dependent_column_name` VARCHAR(255) DEFAULT NULL,
|
||||||
|
`mock_data_type` VARCHAR(255) NOT NULL DEFAULT 'AUTO / REF / SCRIPT / PHONE / DATE / TIMESTAMP / ...',
|
||||||
|
`mock_data_script` TEXT DEFAULT NULL,
|
||||||
|
`update_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
`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;
|
||||||
|
|
||||||
|
ALTER TABLE databasir.table_column_document
|
||||||
|
ADD COLUMN data_type INT NOT NULL DEFAULT 99999 AFTER type;
|
|
@ -17,6 +17,8 @@ public class ColumnMeta {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
private Integer dataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if default value is empty string, will be converted to ''.
|
* if default value is empty string, will be converted to ''.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -67,8 +67,10 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
||||||
Integer columnSize = columnsResult.getInt("COLUMN_SIZE");
|
Integer columnSize = columnsResult.getInt("COLUMN_SIZE");
|
||||||
String columnType = columnsResult.getString("TYPE_NAME");
|
String columnType = columnsResult.getString("TYPE_NAME");
|
||||||
String columnComment = columnsResult.getString("REMARKS");
|
String columnComment = columnsResult.getString("REMARKS");
|
||||||
|
int dataType = columnsResult.getInt("DATA_TYPE");
|
||||||
ColumnMeta columnMeta = ColumnMeta.builder()
|
ColumnMeta columnMeta = ColumnMeta.builder()
|
||||||
.name(columnName)
|
.name(columnName)
|
||||||
|
.dataType(dataType)
|
||||||
.type(columnType)
|
.type(columnType)
|
||||||
.size(columnSize)
|
.size(columnSize)
|
||||||
.decimalDigits(decimalDigits)
|
.decimalDigits(decimalDigits)
|
||||||
|
@ -80,7 +82,6 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
||||||
.build();
|
.build();
|
||||||
columnDocs.add(columnMeta);
|
columnDocs.add(columnMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return columnDocs;
|
return columnDocs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue