Browse Source

feature: support custom table template (#102)

* feat: add table field template field

* feat:update frontend resources
master
vran 3 years ago
committed by GitHub
parent
commit
6b6a7f4e40
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      api/src/main/resources/static/css/33.babc6736.css
  2. 0
      api/src/main/resources/static/css/382.742131d4.css
  3. 0
      api/src/main/resources/static/css/434.742131d4.css
  4. 2
      api/src/main/resources/static/index.html
  5. 4
      api/src/main/resources/static/js/269-legacy.352652f8.js
  6. 1
      api/src/main/resources/static/js/269-legacy.352652f8.js.map
  7. 1
      api/src/main/resources/static/js/269-legacy.bc81144c.js.map
  8. 4
      api/src/main/resources/static/js/269.1b1bbfd9.js
  9. 1
      api/src/main/resources/static/js/269.1b1bbfd9.js.map
  10. 1
      api/src/main/resources/static/js/269.a1a5bd04.js.map
  11. 1
      api/src/main/resources/static/js/298.d866ddf2.js.map
  12. 2
      api/src/main/resources/static/js/33-legacy.61663976.js
  13. 1
      api/src/main/resources/static/js/33-legacy.61663976.js.map
  14. 2
      api/src/main/resources/static/js/33.131d3e1c.js
  15. 1
      api/src/main/resources/static/js/33.131d3e1c.js.map
  16. 33
      api/src/main/resources/static/js/382-legacy.4b48b754.js
  17. 1
      api/src/main/resources/static/js/382-legacy.4b48b754.js.map
  18. 8
      api/src/main/resources/static/js/434.5d6222a1.js
  19. 1
      api/src/main/resources/static/js/434.5d6222a1.js.map
  20. 2
      api/src/main/resources/static/js/492-legacy.4e70196c.js
  21. 1
      api/src/main/resources/static/js/492-legacy.4e70196c.js.map
  22. 2
      api/src/main/resources/static/js/492.3c92832b.js
  23. 1
      api/src/main/resources/static/js/492.3c92832b.js.map
  24. 33
      api/src/main/resources/static/js/682-legacy.6e74a81b.js
  25. 1
      api/src/main/resources/static/js/682-legacy.6e74a81b.js.map
  26. 4
      api/src/main/resources/static/js/app-legacy.3f95f6dc.js
  27. 2
      api/src/main/resources/static/js/app-legacy.3f95f6dc.js.map
  28. 4
      api/src/main/resources/static/js/app.29a225fb.js
  29. 2
      api/src/main/resources/static/js/app.29a225fb.js.map
  30. 1
      core/build.gradle
  31. 3
      core/src/main/java/com/databasir/core/domain/document/data/DocumentTemplatePropertiesResponse.java
  32. 3
      core/src/main/java/com/databasir/core/domain/document/service/DocumentTemplateService.java
  33. 10
      core/src/main/java/com/databasir/core/domain/login/service/LoginService.java
  34. 50
      core/src/main/java/com/databasir/core/infrastructure/event/subscriber/SystemStartedEventSubscriber.java
  35. 2
      dao/src/main/java/com/databasir/dao/enums/DocumentTemplatePropertyType.java
  36. 11
      dao/src/main/java/com/databasir/dao/impl/DocumentTemplatePropertyDao.java

0
api/src/main/resources/static/css/492.babc6736.css → api/src/main/resources/static/css/33.babc6736.css

0
api/src/main/resources/static/css/298.742131d4.css → api/src/main/resources/static/css/382.742131d4.css

0
api/src/main/resources/static/css/682.742131d4.css → api/src/main/resources/static/css/434.742131d4.css

2
api/src/main/resources/static/index.html

@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir</title><script defer="defer" type="module" src="/js/chunk-vendors.787360f3.js"></script><script defer="defer" type="module" src="/js/app.d1a59b80.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.15b40a89.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.405c78b5.js" nomodule></script><script defer="defer" src="/js/app-legacy.433198e1.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir</title><script defer="defer" type="module" src="/js/chunk-vendors.787360f3.js"></script><script defer="defer" type="module" src="/js/app.29a225fb.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.15b40a89.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.405c78b5.js" nomodule></script><script defer="defer" src="/js/app-legacy.3f95f6dc.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

4
api/src/main/resources/static/js/269-legacy.bc81144c.js → api/src/main/resources/static/js/269-legacy.352652f8.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269-legacy.352652f8.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269-legacy.bc81144c.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/269.a1a5bd04.js → api/src/main/resources/static/js/269.1b1bbfd9.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269.1b1bbfd9.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/269.a1a5bd04.js.map

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/298.d866ddf2.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/33-legacy.61663976.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/33-legacy.61663976.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/33.131d3e1c.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/33.131d3e1c.js.map

File diff suppressed because one or more lines are too long

33
api/src/main/resources/static/js/382-legacy.4b48b754.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/382-legacy.4b48b754.js.map

File diff suppressed because one or more lines are too long

8
api/src/main/resources/static/js/298.d866ddf2.js → api/src/main/resources/static/js/434.5d6222a1.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/434.5d6222a1.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/492-legacy.4e70196c.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/492-legacy.4e70196c.js.map

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/492.3c92832b.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/492.3c92832b.js.map

File diff suppressed because one or more lines are too long

33
api/src/main/resources/static/js/682-legacy.6e74a81b.js

File diff suppressed because one or more lines are too long

1
api/src/main/resources/static/js/682-legacy.6e74a81b.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/app-legacy.433198e1.js → api/src/main/resources/static/js/app-legacy.3f95f6dc.js

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/app-legacy.433198e1.js.map → api/src/main/resources/static/js/app-legacy.3f95f6dc.js.map

File diff suppressed because one or more lines are too long

4
api/src/main/resources/static/js/app.d1a59b80.js → api/src/main/resources/static/js/app.29a225fb.js

File diff suppressed because one or more lines are too long

2
api/src/main/resources/static/js/app.d1a59b80.js.map → api/src/main/resources/static/js/app.29a225fb.js.map

File diff suppressed because one or more lines are too long

1
core/build.gradle

@ -33,6 +33,7 @@ dependencies {
implementation 'commons-io:commons-io'
implementation 'com.alibaba:easyexcel'
implementation "org.freemarker:freemarker"
implementation 'com.google.guava:guava:31.1-jre'
implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation "com.squareup.retrofit2:converter-jackson:${retrofitVersion}"

3
core/src/main/java/com/databasir/core/domain/document/data/DocumentTemplatePropertiesResponse.java

@ -16,6 +16,9 @@ import java.util.List;
@AllArgsConstructor
public class DocumentTemplatePropertiesResponse {
@Builder.Default
private List<DocumentTemplatePropertyResponse> tableFieldNameProperties = Collections.emptyList();
@Builder.Default
private List<DocumentTemplatePropertyResponse> columnFieldNameProperties = Collections.emptyList();

3
core/src/main/java/com/databasir/core/domain/document/service/DocumentTemplateService.java

@ -32,6 +32,7 @@ public class DocumentTemplateService {
.stream()
.collect(Collectors.groupingBy(d -> d.getType()));
return DocumentTemplatePropertiesResponse.builder()
.tableFieldNameProperties(propertiesGroupByType.get(TABLE_FIELD_NAME))
.columnFieldNameProperties(propertiesGroupByType.get(COLUMN_FIELD_NAME))
.foreignKeyFieldNameProperties(propertiesGroupByType.get(FOREIGN_KEY_FIELD_NAME))
.indexFieldNameProperties(propertiesGroupByType.get(INDEX_FIELD_NAME))
@ -41,6 +42,6 @@ public class DocumentTemplateService {
public void updateByType(DocumentTemplatePropertiesUpdateRequest request) {
List<DocumentTemplatePropertyPojo> pojoList = documentTemplatePropertiesUpdateRequestConverter.toPojo(request);
documentTemplatePropertyDao.batchInsertOnDuplicateKeyUpdate(pojoList);
documentTemplatePropertyDao.batchInsertOnDuplicateKeyUpdateValue(pojoList);
}
}

10
core/src/main/java/com/databasir/core/domain/login/service/LoginService.java

@ -71,16 +71,6 @@ public class LoginService {
return new AccessTokenRefreshResponse(accessToken, accessTokenExpireAtMilli);
}
public Optional<LoginKeyResponse> getLoginKey(Integer userId) {
return loginDao.selectByUserId(userId)
.map(loginPojo -> LoginKeyResponse.builder()
.accessToken(loginPojo.getAccessToken())
.accessTokenExpireAt(loginPojo.getAccessTokenExpireAt())
.refreshToken(loginPojo.getRefreshToken())
.refreshTokenExpireAt(loginPojo.getRefreshTokenExpireAt())
.build());
}
public LoginKeyResponse generate(Integer userId) {
UserPojo user = userDao.selectById(userId);
String accessToken = jwtTokens.accessToken(user.getEmail());

50
core/src/main/java/com/databasir/core/infrastructure/event/subscriber/SystemStartedEventSubscriber.java

@ -20,10 +20,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
@ -55,16 +52,25 @@ public class SystemStartedEventSubscriber {
}
private void initTemplatePropertiesIfNecessary() {
List<String> ignoreFields = List.of("createAt", "discussionCount", "id");
List<String> ignoreFields = List.of("createAt", "discussionCount", "id",
"columns", "indexes", "triggers", "foreignKeys");
Map<String, String> fieldChineseMap = fieldChineseMap();
BiFunction<Field, DocumentTemplatePropertyType, DocumentTemplatePropertyPojo> mapping = (field, type) -> {
String key = field.getName();
String def = field.getName();
DocumentTemplatePropertyPojo pojo = new DocumentTemplatePropertyPojo();
pojo.setType(type);
pojo.setKey(key);
pojo.setDefaultValue(def);
pojo.setDefaultValue(fieldChineseMap.get(key));
return pojo;
};
// table field name;
Field[] fields = TableDocumentResponse.class.getDeclaredFields();
List<DocumentTemplatePropertyPojo> tableProperties = Arrays.stream(fields)
.filter(field -> !ignoreFields.contains(field.getName()))
.map(field -> mapping.apply(field, DocumentTemplatePropertyType.TABLE_FIELD_NAME))
.collect(Collectors.toList());
// column field name;
Field[] columnFields = TableDocumentResponse.ColumnDocumentResponse.class.getDeclaredFields();
List<DocumentTemplatePropertyPojo> columnProperties = Arrays.stream(columnFields)
@ -94,12 +100,42 @@ public class SystemStartedEventSubscriber {
.collect(Collectors.toList());
List<DocumentTemplatePropertyPojo> properties = new ArrayList<>();
properties.addAll(tableProperties);
properties.addAll(columnProperties);
properties.addAll(indexProperties);
properties.addAll(fkProperties);
properties.addAll(triggerProperties);
documentTemplatePropertyDao.batchInsertOnDuplicateIgnore(properties);
documentTemplatePropertyDao.batchInsertOnDuplicateUpdateDefaultValue(properties);
}
private Map<String, String> fieldChineseMap() {
Map<String, String> map = new HashMap<>(32);
map.put("name", "名称");
map.put("type", "类型");
map.put("comment", "注释");
map.put("description", "描述");
map.put("size", "长度");
map.put("decimalDigits", "浮点精度");
map.put("isPrimaryKey", "主键");
map.put("nullable", "可空");
map.put("autoIncrement", "自增");
map.put("defaultValue", "默认值");
map.put("isUnique", "唯一");
map.put("columnNames", "列名");
map.put("fkName", "外键名");
map.put("fkTableName", "外键表名");
map.put("fkColumnName", "外键列名");
map.put("pkName", "主键名");
map.put("pkTableName", "主键表名");
map.put("pkColumnName", "主键列名");
map.put("updateRule", "更新规则");
map.put("deleteRule", "删除规则");
map.put("timing", "触发时机");
map.put("manipulation", "触发器");
map.put("statement", "表达式");
map.put("triggerCreateAt", "创建时间");
return map;
}
private void initDatabaseTypesIfNecessary() {

2
dao/src/main/java/com/databasir/dao/enums/DocumentTemplatePropertyType.java

@ -2,6 +2,6 @@ package com.databasir.dao.enums;
public enum DocumentTemplatePropertyType {
INDEX_FIELD_NAME, COLUMN_FIELD_NAME, TRIGGER_FIELD_NAME, FOREIGN_KEY_FIELD_NAME;
TABLE_FIELD_NAME, INDEX_FIELD_NAME, COLUMN_FIELD_NAME, TRIGGER_FIELD_NAME, FOREIGN_KEY_FIELD_NAME;
}

11
dao/src/main/java/com/databasir/dao/impl/DocumentTemplatePropertyDao.java

@ -25,22 +25,21 @@ public class DocumentTemplatePropertyDao extends BaseDao<DocumentTemplatePropert
super(DOCUMENT_TEMPLATE_PROPERTY, DocumentTemplatePropertyPojo.class);
}
public void batchInsertOnDuplicateIgnore(Collection<DocumentTemplatePropertyPojo> data) {
public void batchInsertOnDuplicateUpdateDefaultValue(Collection<DocumentTemplatePropertyPojo> data) {
if (data == null || data.isEmpty()) {
return;
}
List<InsertReturningStep<DocumentTemplatePropertyRecord>> query = data.stream()
.map(pojo ->
getDslContext()
.map(pojo -> getDslContext()
.insertInto(DOCUMENT_TEMPLATE_PROPERTY)
.set(getDslContext().newRecord(DOCUMENT_TEMPLATE_PROPERTY, pojo))
.onDuplicateKeyIgnore())
.onDuplicateKeyUpdate()
.set(DOCUMENT_TEMPLATE_PROPERTY.DEFAULT_VALUE, pojo.getDefaultValue()))
.collect(Collectors.toList());
getDslContext().batch(query).execute();
}
public void batchInsertOnDuplicateKeyUpdate(Collection<DocumentTemplatePropertyPojo> data) {
public void batchInsertOnDuplicateKeyUpdateValue(Collection<DocumentTemplatePropertyPojo> data) {
if (data == null || data.isEmpty()) {
return;
}

Loading…
Cancel
Save