Skip to content

Commit e2450b2

Browse files
authored
Merge pull request #1244 from scottsut/master
feat: 1.0.0-beta.3 release
2 parents 5624919 + 3692b1c commit e2450b2

File tree

709 files changed

+30569
-11248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

709 files changed

+30569
-11248
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
2+
# IDE
13
.idea
4+
.DS_Store
25

36
/static
47

config/datart.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ server.address=0.0.0.0
1515
datart.address=http://127.0.0.1
1616
datart.send-mail=false
1717
datart.webdriver-path=http://127.0.0.1:4444/wd/hub
18+
datart.user.register=true
19+
# 注册邮件有效期/小时, 默认48小时
20+
datart.register.expire-hours=
21+
# 邀请邮件有效期/小时, 默认48小时
22+
datart.invite.expire-hours=
23+
# 租户管理模式:platform-平台(默认),team-团队
24+
datart.tenant-management-mode=platform
25+
# 团队模式初始组织拥有者用户名/密码: 仅团队模式且两者都不为空时重置
26+
datart.admin.username=
27+
datart.admin.password=

config/profiles/application-config.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ spring:
3030
# name: "attributes.name"
3131
# avatar: "attributes.avatar"
3232

33+
# ldap config
34+
35+
# ldap:
36+
# urls: ldap://{IP}:{PORT}
37+
# base: xxx
38+
# username: {username}
39+
# password: {password}
40+
3341
# mail config
3442

3543
# mail:
@@ -62,19 +70,31 @@ spring:
6270
server:
6371
port: ${server.port:8080}
6472
address: ${server.ip:0.0.0.0}
65-
ssl.enabled: false
66-
ssl.key-store: keystore.p12 # Absolute path
67-
ssl.key-store-password: password
68-
ssl.keyStoreType: PKCS12
69-
ssl.keyAlias: tomcat
73+
ssl:
74+
enabled: false
75+
key-store: keystore.p12 # Absolute path
76+
key-store-password: password
77+
keyStoreType: PKCS12
78+
keyAlias: tomcat
7079

7180
datart:
7281
server:
7382
address: ${datart.address:http://127.0.0.1:8080}
7483

84+
# 租户管理模式:platform-平台(默认),team-团队
85+
tenant-management-mode: platform
86+
# 团队管理员用户名/密码: 仅team模式且两者都不为空时重置
87+
admin:
88+
username:
89+
password:
90+
7591
user:
92+
register: true # 是否允许注册
7693
active:
7794
send-mail: ${datart.send-mail:false} # 注册用户时是否需要邮件验证激活
95+
expire-hours: ${datart.register.expire-hours:48} # 注册邮件有效期/小时
96+
invite:
97+
expire-hours: ${datart.invite.expire-hours:48} # 邀请邮件有效期/小时
7898

7999
security:
80100
token:

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>datart-parent</artifactId>
77
<groupId>datart</groupId>
8-
<version>1.0.0-beta.2</version>
8+
<version>1.0.0-beta.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

core/src/main/java/datart/core/base/consts/AttachmentType.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@
22

33
public enum AttachmentType {
44

5-
EXCEL,
5+
EXCEL(".xlsx"),
66

7-
IMAGE
7+
IMAGE(".png"),
88

9+
PDF(".pdf");
10+
11+
private String suffix;
12+
13+
AttachmentType(String suffix) {
14+
this.suffix = suffix;
15+
}
16+
17+
public void setSuffix(String suffix) {
18+
this.suffix = suffix;
19+
}
20+
21+
public String getSuffix() {
22+
return suffix;
23+
}
924
}

core/src/main/java/datart/core/base/consts/Const.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public class Const {
5959
/**
6060
* 权限变量
6161
*/
62-
// //管理员权限,拥有所有数据的权限
63-
// public static final String ALL_PERMISSION = "@ALL_PERMISSION@";
62+
public static final String ALL_PERMISSION = "@DATART_ALL_PERMISSION@";
6463

6564
/**
6665
* Token Key
@@ -101,4 +100,6 @@ public class Const {
101100

102101
public static final String ENCRYPT_FLAG = "_encrypted_";
103102

103+
public static final String USER_DEFAULT_PSW = "123456";
104+
104105
}

core/src/main/java/datart/core/base/consts/FileOwner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public enum FileOwner {
1414

1515
SCHEDULE("schedule/files/"),
1616

17-
DOWNLOAD("download/");
17+
DOWNLOAD("download/"),
18+
19+
EXPORT("export/");
1820

1921
private final String path;
2022

core/src/main/java/datart/core/base/consts/ShareType.java renamed to core/src/main/java/datart/core/base/consts/ShareAuthenticationMode.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
package datart.core.base.consts;
2020

21-
public enum ShareType {
21+
public enum ShareAuthenticationMode {
2222

23-
TOKEN_SHARE,
23+
NONE,
2424

25-
PASSWORD_SHARE,
25+
CODE,
26+
27+
LOGIN
2628

27-
AUTH_SHARE
2829
}

core/src/main/java/datart/core/base/consts/SharePermission.java

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package datart.core.base.consts;
2+
3+
public enum ShareRowPermissionBy {
4+
5+
// use share creator's permission
6+
CREATOR,
7+
// use visitor's permission
8+
VISITOR
9+
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package datart.core.base.consts;
2+
3+
public enum TenantManagementMode {
4+
/** 团队模式 */
5+
TEAM,
6+
/** 平台模式 */
7+
PLATFORM;
8+
9+
}

core/src/main/java/datart/core/common/Application.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,26 @@
1818

1919
package datart.core.common;
2020

21+
import datart.core.base.consts.TenantManagementMode;
22+
import lombok.extern.slf4j.Slf4j;
23+
import org.apache.commons.lang3.BooleanUtils;
2124
import org.apache.commons.lang3.StringUtils;
2225
import org.springframework.beans.BeansException;
2326
import org.springframework.context.ApplicationContext;
2427
import org.springframework.context.ApplicationContextAware;
2528
import org.springframework.lang.NonNull;
2629
import org.springframework.stereotype.Component;
2730

31+
import static datart.core.base.consts.TenantManagementMode.PLATFORM;
32+
2833
@Component
34+
@Slf4j
2935
public class Application implements ApplicationContextAware {
3036

3137
private static ApplicationContext context;
3238

39+
private static TenantManagementMode currMode;
40+
3341
@Override
3442
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
3543
Application.context = applicationContext;
@@ -43,6 +51,10 @@ public static <T> T getBean(Class<T> t) {
4351
return context.getBean(t);
4452
}
4553

54+
public static <T> T getBean(String beanName, Class<T> t) {
55+
return context.getBean(beanName, t);
56+
}
57+
4658
public static String getProperty(String key) {
4759
return context.getEnvironment().getProperty(key);
4860
}
@@ -74,8 +86,36 @@ public static String getApiPrefix() {
7486
return getProperty("datart.server.path-prefix");
7587
}
7688

89+
public static String getServerPrefix() {
90+
return getProperty("server.servlet.context-path","/");
91+
}
92+
7793
public static String getTokenSecret() {
7894
return getProperty("datart.security.token.secret", "d@a$t%a^r&a*t");
7995
}
8096

97+
public static boolean canRegister() {
98+
return BooleanUtils.toBoolean(getProperty("datart.user.register", "true"));
99+
}
100+
101+
public static String getAdminId() {
102+
if (getCurrMode().equals(TenantManagementMode.TEAM)){
103+
return getProperty("datart.admin-id", "datart-admin");
104+
}
105+
return "";
106+
}
107+
108+
public static TenantManagementMode getCurrMode() {
109+
if (currMode == null) {
110+
String mode = Application.getProperty("datart.tenant-management-mode");
111+
try {
112+
return TenantManagementMode.valueOf(mode.toUpperCase());
113+
} catch (Exception e) {
114+
log.warn("Unrecognized tenant-management-mode: '{}', and this will run in platform tenant-management-mode", mode);
115+
}
116+
currMode = PLATFORM;
117+
}
118+
return currMode;
119+
}
120+
81121
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Datart
3+
* <p>
4+
* Copyright 2021
5+
* <p>
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package datart.core.common;
20+
21+
import org.apache.ibatis.javassist.ClassPool;
22+
import org.apache.ibatis.javassist.CtClass;
23+
import org.apache.ibatis.javassist.CtMethod;
24+
25+
public class ClassTransformer {
26+
27+
public static void transform() {
28+
transformSqlWriter();
29+
transformFlyway();
30+
}
31+
32+
private static void transformSqlWriter() {
33+
try {
34+
ClassPool classPool = ClassPool.getDefault();
35+
CtClass ctClass = classPool.get("org.apache.calcite.sql.pretty.SqlPrettyWriter");
36+
CtMethod keyword = ctClass.getDeclaredMethod("keyword");
37+
keyword.setBody("{ maybeWhitespace($1);" +
38+
" buf.append($1);" +
39+
" if (!$1.equals(\"\")) {" +
40+
" setNeedWhitespace(needWhitespaceAfter($1));" +
41+
" } " +
42+
"return;} ");
43+
ctClass.toClass();
44+
} catch (Exception e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
49+
private static void transformFlyway() {
50+
try {
51+
ClassPool classPool = ClassPool.getDefault();
52+
CtClass ctClass = classPool.get("org.flywaydb.core.internal.database.mysql.MySQLConnection");
53+
CtMethod getIntVariableValue = ctClass.getDeclaredMethod("getIntVariableValue");
54+
getIntVariableValue.setBody("return 0;");
55+
56+
CtMethod doRestoreOriginalState = ctClass.getDeclaredMethod("doRestoreOriginalState");
57+
doRestoreOriginalState.setBody("return;");
58+
59+
CtMethod hasUserVariableResetCapability = ctClass.getDeclaredMethod("hasUserVariableResetCapability");
60+
hasUserVariableResetCapability.setBody("{return false;}");
61+
ctClass.toClass();
62+
} catch (Exception e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}

core/src/main/java/datart/core/common/DateUtils.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
package datart.core.common;
2020

21+
import org.apache.commons.lang3.StringUtils;
22+
import org.apache.commons.lang3.time.DateFormatUtils;
23+
24+
import java.util.Date;
25+
2126
public class DateUtils {
2227

2328
private static final String[] FMT = {"y", "M", "d", "H", "m", "s", "S"};
@@ -46,4 +51,16 @@ public static String inferDateFormat(String src) {
4651
return stringBuilder.toString();
4752
}
4853

54+
public static boolean isDateFormat(String format) {
55+
return StringUtils.isNotBlank(format) && "yyyy-MM-dd".equalsIgnoreCase(format.trim());
56+
}
57+
58+
public static boolean isDateTimeFormat(String format) {
59+
return StringUtils.isNotBlank(format) && "yyyy-MM-dd HH:mm:ss".equalsIgnoreCase(format.trim());
60+
}
61+
62+
public static String withTimeString(String name) {
63+
return name + DateFormatUtils.format(new Date(), DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
64+
}
65+
4966
}

0 commit comments

Comments
 (0)