Skip to content

Commit c79a348

Browse files
committed
[fit] 完善注释
1 parent 21fe248 commit c79a348

File tree

11 files changed

+106
-19
lines changed

11 files changed

+106
-19
lines changed

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-jakarta/src/test/java/modelengine/fitframework/validation/LocaleValidationController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation;
28

39
import modelengine.fit.http.annotation.PostMapping;
@@ -12,7 +18,7 @@
1218
* 地区验证控制器 - 测试ValidationHandler与LocaleContextMessageInterpolator的集成
1319
*
1420
* @author 阮睿
15-
* @since 2025-01-27
21+
* @since 2025-08-01
1622
*/
1723
@Component
1824
@RequestMapping(path = "/validation/locale", group = "地区验证测试接口")
@@ -21,6 +27,8 @@ public class LocaleValidationController {
2127

2228
/**
2329
* 测试验证消息的地区化 - 使用简单参数
30+
*
31+
* @param company 表示注解验证类 {@link Company}。
2432
*/
2533
@PostMapping(path = "/simple", description = "测试简单参数的地区化验证消息")
2634
public void validateSimpleParam(@RequestBody @Valid Company company) {}

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-jakarta/src/test/java/modelengine/fitframework/validation/LocaleValidationControllerTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation;
28

39
import modelengine.fit.http.client.HttpClassicClientResponse;
@@ -23,7 +29,7 @@
2329
* {@link LocaleValidationController} 的测试集。
2430
*
2531
* @author 阮睿
26-
* @since 2025-07-18
32+
* @since 2025-08-01
2733
*/
2834
@MvcTest(classes = {LocaleValidationController.class})
2935
@DisplayName("测试地区化验证消息功能")

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-jakarta/src/test/java/modelengine/fitframework/validation/data/localeResolveConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation.data;
28

39
import modelengine.fit.http.util.i18n.LocaleResolveFilter;
410
import modelengine.fitframework.annotation.Bean;
511
import modelengine.fitframework.annotation.Component;
612

13+
/**
14+
* {@link LocaleResolveFilter} 配置类
15+
*
16+
* @author 阮睿
17+
* @since 2025-08-01
18+
*/
719
@Component
820
public class localeResolveConfig {
921
@Bean

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-javax/src/test/java/modelengine/fitframework/validation/LocaleValidationController.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation;
28

39
import javax.validation.Valid;
4-
import javax.validation.constraints.NotBlank;
5-
import javax.validation.constraints.Min;
610

7-
import modelengine.fit.http.util.i18n.LocaleResolveFilter;
8-
import modelengine.fitframework.annotation.Bean;
911
import modelengine.fitframework.annotation.Component;
10-
import modelengine.fitframework.util.LocaleContextHolder;
1112
import modelengine.fitframework.validation.data.Company;
12-
import modelengine.fitframework.validation.data.Employee;
1313
import modelengine.fit.http.annotation.PostMapping;
1414
import modelengine.fit.http.annotation.RequestBody;
1515
import modelengine.fit.http.annotation.RequestMapping;
1616

17-
import java.util.Locale;
18-
1917
/**
2018
* 地区验证控制器 - 测试ValidationHandler与LocaleContextMessageInterpolator的集成
2119
*
2220
* @author 阮睿
23-
* @since 2025-01-27
21+
* @since 2025-08-01
2422
*/
2523
@Component
2624
@RequestMapping(path = "/validation/locale", group = "地区验证测试接口")
@@ -29,6 +27,8 @@ public class LocaleValidationController {
2927

3028
/**
3129
* 测试验证消息的地区化 - 使用简单参数
30+
*
31+
* @param company 表示注解验证类 {@link Company}。
3232
*/
3333
@PostMapping(path = "/simple", description = "测试简单参数的地区化验证消息")
3434
public void validateSimpleParam(@RequestBody @Valid Company company) {}

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-javax/src/test/java/modelengine/fitframework/validation/LocaleValidationControllerTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation;
28

39
import modelengine.fit.http.client.HttpClassicClientResponse;
@@ -23,7 +29,7 @@
2329
* {@link LocaleValidationController} 的测试集。
2430
*
2531
* @author 阮睿
26-
* @since 2025-07-18
32+
* @since 2025-08-01
2733
*/
2834
@MvcTest(classes = {LocaleValidationController.class})
2935
@DisplayName("测试地区化验证消息功能")

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-javax/src/test/java/modelengine/fitframework/validation/data/localeResolveConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fitframework.validation.data;
28

39
import modelengine.fit.http.util.i18n.LocaleResolveFilter;
410
import modelengine.fitframework.annotation.Bean;
511
import modelengine.fitframework.annotation.Component;
612

13+
/**
14+
* {@link LocaleResolveFilter} 配置类
15+
*
16+
* @author 阮睿
17+
* @since 2025-08-01
18+
*/
719
@Component
820
public class localeResolveConfig {
921
@Bean

framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/util/i18n/DefualtLocaleResolver.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* This file is a part of the ModelEngine Project.
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
6+
67
package modelengine.fit.http.util.i18n;
78

89
import modelengine.fit.http.Cookie;
@@ -11,7 +12,12 @@
1112

1213
import java.util.Locale;
1314

14-
15+
/**
16+
* 默认地区解析器。
17+
*
18+
* @author 阮睿
19+
* @since 2025-08-01
20+
*/
1521
public class DefualtLocaleResolver implements LocaleResolver{
1622

1723
public static final String DEFAULT_COOKIE_NAME = "locale";

framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/util/i18n/LocaleResolveFilter.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
17
package modelengine.fit.http.util.i18n;
28

39
import modelengine.fit.http.server.*;
@@ -8,6 +14,12 @@
814
import java.util.List;
915
import java.util.Locale;
1016

17+
/**
18+
* 地区解析过滤器。
19+
*
20+
* @author 阮睿
21+
* @since 2025-08-01
22+
*/
1123
public class LocaleResolveFilter implements HttpServerFilter {
1224

1325
private LocaleResolver localeResolver = null;
@@ -46,13 +58,21 @@ public List<String> mismatchPatterns() {
4658
return mismatchPatterns;
4759
}
4860

61+
/**
62+
* 过滤请求,从请求中解析地区值并放入线程上下文和cookie。
63+
*
64+
* @param request 表示服务器请求 {@link HttpClassicServerRequest}。
65+
* @param response 表示服务器响应 {@link HttpClassicServerResponse}。
66+
* @param chain 过滤链 {@link HttpServerFilterChain}。
67+
*/
4968
@Override
50-
public void doFilter(HttpClassicServerRequest request, HttpClassicServerResponse response, HttpServerFilterChain chain) throws DoHttpServerFilterException {
69+
public void doFilter(HttpClassicServerRequest request, HttpClassicServerResponse response,
70+
HttpServerFilterChain chain) throws DoHttpServerFilterException {
5171
try {
5272
// 如果参数中带有地区,则直接设置地区
53-
String paramLocale = request.queries().first("locale").orElse( null);
73+
String paramLocale = request.queries().first("locale").orElse(null);
5474
Locale responseLocale = null;
55-
if(paramLocale != null && !paramLocale.trim().isEmpty()){
75+
if (paramLocale != null && !paramLocale.trim().isEmpty()) {
5676
responseLocale = Locale.forLanguageTag(paramLocale);
5777
LocaleContextHolder.setLocaleContext(new LocaleContext(responseLocale));
5878
}

framework/fit/java/fit-builtin/services/fit-http-classic/definition/src/main/java/modelengine/fit/http/util/i18n/LocaleResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
/**
1414
* 地区解析器接口,用于从HTTP请求中解析用户的地区设置
1515
*
16-
* @author fit-framework
17-
* @since 2025-01-01
16+
* @author 阮睿
17+
* @since 2025-08-01
1818
*/
1919
public interface LocaleResolver {
2020

framework/fit/java/fit-util/src/main/java/modelengine/fitframework/util/LocaleContext.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
import java.util.Locale;
1010

11+
/**
12+
* 地区上下文。
13+
*
14+
* @author 阮睿
15+
* @since 2025-08-01
16+
*/
1117
public class LocaleContext {
1218
private final Locale locale;
1319

0 commit comments

Comments
 (0)