Skip to content

Commit e784ec3

Browse files
committed
Added Webhook, added gRPC Proxy, optimized countdown timer interface, homepage dashboad permission control, added management view screen to API list
1 parent e8172e8 commit e784ec3

File tree

364 files changed

+62881
-44234
lines changed

Some content is hidden

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

364 files changed

+62881
-44234
lines changed

build.gradle

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
id 'com.github.jk1.dependency-license-report' version '2.9'
1616

1717
id "org.sonarqube" version "5.1.0.4882"
18-
18+
id 'com.google.protobuf' version '0.9.4'
1919
id "jacoco"
2020
id 'java'
2121
}
@@ -35,7 +35,7 @@ licenseReport {
3535

3636
allprojects {
3737
group = 'tpi.dgrv4'
38-
version = 'release-rc-v4.5.6.0-43-ge59946471'
38+
version = 'release-rc-v4.5.13.1-7-g4901c09b3'
3939
apply plugin: 'io.spring.dependency-management'
4040

4141
repositories {
@@ -62,8 +62,8 @@ subprojects {
6262

6363

6464
dependencies {
65-
implementation files("${rootDir}/libsext/dgrv4_CodecUtil-v4.5.6.0-43-ge59946471-lib.jar")
66-
implementation files("${rootDir}/libsext/dgrv4_HttpUtil-v4.5.6.0-43-ge59946471-lib.jar")
65+
implementation files("${rootDir}/libsext/dgrv4_CodecUtil-v4.5.13.1-7-g4901c09b3-lib.jar")
66+
implementation files("${rootDir}/libsext/dgrv4_HttpUtil-v4.5.13.1-7-g4901c09b3-lib.jar")
6767

6868
implementation ('org.springframework.boot:spring-boot-starter-data-jpa'){
6969
exclude group: 'ch.qos.logback', module: 'logback-classic'
@@ -229,7 +229,33 @@ project(':dgrv4_Gateway_serv'){
229229

230230
// 修正上方排除的 commons-beanutils:commons-beanutils
231231
implementation 'commons-beanutils:commons-beanutils:1.11.0'
232+
233+
// gRPC Proxy
234+
implementation 'net.devh:grpc-server-spring-boot-starter:2.15.0.RELEASE'
235+
implementation 'io.grpc:grpc-netty-shaded:1.61.0'
236+
implementation 'io.grpc:grpc-protobuf:1.61.0'
237+
implementation 'io.grpc:grpc-stub:1.61.0'
238+
implementation 'org.yaml:snakeyaml:2.2'
239+
240+
// 添加對 Netty 的非遮蔽(non-shaded)依賴,以便 TLS 相關功能
241+
implementation 'io.grpc:grpc-netty:1.61.0'
242+
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.61.Final'
243+
}
232244

245+
protobuf {
246+
protoc {
247+
artifact = "com.google.protobuf:protoc:3.25.1"
248+
}
249+
plugins {
250+
grpc {
251+
artifact = 'io.grpc:protoc-gen-grpc-java:1.61.0'
252+
}
253+
}
254+
generateProtoTasks {
255+
all()*.plugins {
256+
grpc {}
257+
}
258+
}
233259
}
234260

235261
task createVersionTxt() {

dgrv4_Common_lib/src/main/java/tpi/dgrv4/common/component/cache/core/DaoGenericCache.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class DaoGenericCache implements IDaoGenericCache<String, Object> {
1717

1818
private static final Long DEFAULT_CACHE_TIMEOUT = 120000L; // 預設快取存活時間 120sec
1919

20-
public final static long BUFFER_INTERVAL = 6000L; // 預設快取緩衝時間 6sec
20+
public static final long BUFFER_INTERVAL = 6000L; // 預設快取緩衝時間 6sec
2121

2222
protected Long cacheTimeout;
2323

@@ -190,9 +190,7 @@ protected boolean isExpired(String key) {
190190
}
191191
long expirationTimestampMillis = cv.getCreatedAt() + this.cacheTimeout;
192192
long currentTimestampMillis = System.currentTimeMillis();
193-
boolean isExpired = currentTimestampMillis > expirationTimestampMillis;
194-
195-
return isExpired;
193+
return currentTimestampMillis > expirationTimestampMillis;
196194
}
197195

198196
@Override

dgrv4_Common_lib/src/main/java/tpi/dgrv4/common/component/cache/proxy/DaoCacheProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class DaoCacheProxy {
3535
private final CacheValueAdapter adapter;
3636

3737
@Autowired
38-
public DaoCacheProxy(ObjectMapper objectMapper, DaoGenericCache cache) {
38+
protected DaoCacheProxy(ObjectMapper objectMapper, DaoGenericCache cache) {
3939
super();
4040
this.adapter = new CacheValueKryoAdapter(getClass().getName(), this::kryoRegistration);
4141
this.objectMapper = objectMapper;

dgrv4_Common_lib/src/main/java/tpi/dgrv4/common/component/validator/BCRIStringValidator.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package tpi.dgrv4.common.component.validator;
22

3-
import java.util.Objects;
43
import java.util.regex.Matcher;
54
import java.util.regex.Pattern;
65

76
import org.springframework.util.StringUtils;
87

98
import tpi.dgrv4.common.constant.TsmpDpAaRtnCode;
9+
import tpi.dgrv4.common.keeper.ITPILogger;
1010
import tpi.dgrv4.common.vo.BeforeControllerRespItem;
1111

1212

@@ -37,20 +37,16 @@ protected void doValidate(BeforeControllerRespItem item, String fieldValue) {
3737

3838
private void checkIsRequired(BeforeControllerRespItem item, String fieldValue) {
3939
Boolean isRequired = getRespValue(item.getIsRequired());
40-
if (!Objects.isNull(isRequired)) {
41-
if (isRequired && StringUtils.isEmpty(fieldValue)) {
42-
throw TsmpDpAaRtnCode._1350.throwing(getWrappedFieldName());
43-
}
40+
if (isRequired != null && isRequired && !StringUtils.hasLength(fieldValue)) {
41+
throw TsmpDpAaRtnCode._1350.throwing(getWrappedFieldName());
4442
}
4543
}
4644

4745
private void checkMaxLength(BeforeControllerRespItem item, String fieldValue) {
4846
Integer maxLength = getRespValue(item.getMaxLength());
49-
if (maxLength != null) {
50-
if (fieldValue != null && fieldValue.length() > maxLength) {
51-
throw TsmpDpAaRtnCode._1351.throwing(getWrappedFieldName(), //
47+
if (maxLength != null && fieldValue != null && fieldValue.length() > maxLength) {
48+
throw TsmpDpAaRtnCode._1351.throwing(getWrappedFieldName(), //
5249
String.valueOf(maxLength), String.valueOf(fieldValue.length()));
53-
}
5450
}
5551
}
5652

@@ -76,7 +72,7 @@ private void checkPattern(BeforeControllerRespItem item, String fieldValue) {
7672
try {
7773
p = Pattern.compile(regex);
7874
} catch (Exception e) {
79-
this.logger.debug("轉換正則表達式失敗: " + regex);
75+
ITPILogger.tl.debug("轉換正則表達式失敗: " + regex);
8076
throw TsmpDpAaRtnCode._1297.throwing();
8177
}
8278

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
package tpi.dgrv4.common.component.validator;
2-
3-
import java.lang.reflect.Field;
4-
import java.util.Optional;
5-
6-
import tpi.dgrv4.common.constant.TsmpDpAaRtnCode;
7-
import tpi.dgrv4.common.exceptions.TsmpDpAaException;
8-
import tpi.dgrv4.common.keeper.ITPILogger;
9-
import tpi.dgrv4.common.vo.BeforeControllerRespItem;
10-
11-
/**
12-
* 'BCRIV' is the abbreviation of 'BeforeControllerRespItemValidator'
13-
* @author Kim
14-
*/
15-
public abstract class BCRIVFactory implements BCRIVFactoryIfs {
16-
17-
private static ITPILogger logger;
18-
19-
private final BeforeControllerRespItem item;
20-
21-
public BCRIVFactory(BeforeControllerRespItem item) {
22-
this.item = item;
23-
}
24-
25-
@Override
26-
public BCRIValidatorIfs getValidator(Object obj) {
27-
try {
28-
String fieldName = this.item.getField();
29-
Field field = obj.getClass().getDeclaredField(fieldName);
30-
31-
// 驗證欄位資料型態與Item所指定的type是否相符
32-
checkFieldType(field.getType());
33-
34-
field.setAccessible(true);
35-
return createValidator(this.item, field, obj);
36-
} catch (TsmpDpAaException e) {
37-
throw e;
38-
} catch (Exception e) {
39-
logger.debug("" + e);
40-
throw TsmpDpAaRtnCode._1297.throwing();
41-
}
42-
}
43-
44-
private void checkFieldType(Class<?> actualFieldType) throws Exception {
45-
Optional<Class<?>> opt = isFieldTypeCorrect(actualFieldType);
46-
if (!opt.isPresent()) {
47-
throw new Exception("未正確執行資料型別判定");
48-
}
49-
Class<?> expectedFieldType = opt.get();
50-
if (!actualFieldType.equals(expectedFieldType)) {
51-
String expectedType = expectedFieldType.getSimpleName();
52-
String actualType = actualFieldType.getSimpleName();
53-
throw new Exception("限制式型別(" + expectedType + ")與實際資料型別(" + actualType + ")不符");
54-
}
55-
}
56-
57-
protected abstract BCRIValidatorIfs createValidator(BeforeControllerRespItem item, Field field, Object obj) //
58-
throws Exception;
59-
60-
public static void setLogger(ITPILogger logger) {
61-
BCRIVFactory.logger = logger;
62-
}
63-
1+
package tpi.dgrv4.common.component.validator;
2+
3+
import java.lang.reflect.Field;
4+
import java.util.Optional;
5+
6+
import tpi.dgrv4.common.constant.TsmpDpAaRtnCode;
7+
import tpi.dgrv4.common.exceptions.TsmpDpAaException;
8+
import tpi.dgrv4.common.keeper.ITPILogger;
9+
import tpi.dgrv4.common.vo.BeforeControllerRespItem;
10+
11+
/**
12+
* 'BCRIV' is the abbreviation of 'BeforeControllerRespItemValidator'
13+
* @author Kim
14+
*/
15+
public abstract class BCRIVFactory implements BCRIVFactoryIfs {
16+
17+
private static ITPILogger logger;
18+
19+
private final BeforeControllerRespItem item;
20+
21+
protected BCRIVFactory(BeforeControllerRespItem item) {
22+
this.item = item;
23+
}
24+
25+
@Override
26+
public BCRIValidatorIfs getValidator(Object obj) {
27+
try {
28+
String fieldName = this.item.getField();
29+
Field field = obj.getClass().getDeclaredField(fieldName);
30+
31+
// 驗證欄位資料型態與Item所指定的type是否相符
32+
checkFieldType(field.getType());
33+
34+
field.setAccessible(true);
35+
return createValidator(this.item, field, obj);
36+
} catch (TsmpDpAaException e) {
37+
throw e;
38+
} catch (Exception e) {
39+
logger.debug("" + e);
40+
throw TsmpDpAaRtnCode._1297.throwing();
41+
}
42+
}
43+
44+
private void checkFieldType(Class<?> actualFieldType) throws Exception {
45+
Optional<Class<?>> opt = isFieldTypeCorrect(actualFieldType);
46+
if (!opt.isPresent()) {
47+
throw new Exception("未正確執行資料型別判定");
48+
}
49+
Class<?> expectedFieldType = opt.get();
50+
if (!actualFieldType.equals(expectedFieldType)) {
51+
String expectedType = expectedFieldType.getSimpleName();
52+
String actualType = actualFieldType.getSimpleName();
53+
throw new Exception("限制式型別(" + expectedType + ")與實際資料型別(" + actualType + ")不符");
54+
}
55+
}
56+
57+
protected abstract BCRIValidatorIfs createValidator(BeforeControllerRespItem item, Field field, Object obj) //
58+
throws Exception;
59+
60+
public static void setLogger(ITPILogger logger) {
61+
BCRIVFactory.logger = logger;
62+
}
63+
6464
}
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
package tpi.dgrv4.common.component.validator;
2-
3-
import tpi.dgrv4.common.keeper.ITPILogger;
4-
import tpi.dgrv4.common.vo.BeforeControllerRespItem;
5-
import tpi.dgrv4.common.vo.BeforeControllerRespValue;
6-
7-
/**
8-
* 'BCRI' is the abbreviation of 'BeforeControllerRespItem'
9-
* @author Kim
10-
*/
11-
public abstract class BCRIValidator<V> implements BCRIValidatorIfs {
12-
13-
private final BeforeControllerRespItem item;
14-
15-
private final V fieldValue;
16-
17-
protected static ITPILogger logger;
18-
19-
public BCRIValidator(BeforeControllerRespItem item, V fieldValue) {
20-
this.item = item;
21-
this.fieldValue = fieldValue;
22-
}
23-
24-
@Override
25-
public void validate() {
26-
doValidate(this.item, this.fieldValue);
27-
}
28-
29-
protected final <T> T getRespValue(BeforeControllerRespValue<T> respValue) {
30-
if (respValue != null) {
31-
return respValue.getValue();
32-
}
33-
return null;
34-
}
35-
36-
protected final String getWrappedFieldName() {
37-
return "{{" + this.item.getField() + "}}";
38-
}
39-
40-
protected abstract void doValidate(BeforeControllerRespItem item, V fieldValue);
41-
42-
public static void setLogger(ITPILogger logger) {
43-
BCRIValidator.logger = logger;
44-
}
45-
1+
package tpi.dgrv4.common.component.validator;
2+
3+
import tpi.dgrv4.common.keeper.ITPILogger;
4+
import tpi.dgrv4.common.vo.BeforeControllerRespItem;
5+
import tpi.dgrv4.common.vo.BeforeControllerRespValue;
6+
7+
/**
8+
* 'BCRI' is the abbreviation of 'BeforeControllerRespItem'
9+
* @author Kim
10+
*/
11+
public abstract class BCRIValidator<V> implements BCRIValidatorIfs {
12+
13+
private final BeforeControllerRespItem item;
14+
15+
private final V fieldValue;
16+
17+
protected static ITPILogger logger;
18+
19+
protected BCRIValidator(BeforeControllerRespItem item, V fieldValue) {
20+
this.item = item;
21+
this.fieldValue = fieldValue;
22+
}
23+
24+
@Override
25+
public void validate() {
26+
doValidate(this.item, this.fieldValue);
27+
}
28+
29+
protected final <T> T getRespValue(BeforeControllerRespValue<T> respValue) {
30+
if (respValue != null) {
31+
return respValue.getValue();
32+
}
33+
return null;
34+
}
35+
36+
protected final String getWrappedFieldName() {
37+
return "{{" + this.item.getField() + "}}";
38+
}
39+
40+
protected abstract void doValidate(BeforeControllerRespItem item, V fieldValue);
41+
42+
public static void setLogger(ITPILogger logger) {
43+
BCRIValidator.logger = logger;
44+
}
45+
4646
}

0 commit comments

Comments
 (0)