Skip to content

Commit 9235ea1

Browse files
author
wuayee
committed
[appBuilder] 增加appType国际化的能力
1 parent 0ffca2b commit 9235ea1

File tree

10 files changed

+60
-36
lines changed

10 files changed

+60
-36
lines changed

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/controller/AppTypeController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import modelengine.fit.jane.task.gateway.Authenticator;
1212
import modelengine.fit.jober.aipp.dto.AppTypeDto;
1313
import modelengine.fit.jober.aipp.service.AppTypeService;
14+
import modelengine.jade.common.locale.LocaleUtil;
1415
import modelengine.jade.service.annotations.CarverSpan;
1516
import modelengine.jade.service.annotations.SpanAttr;
1617

@@ -25,6 +26,7 @@
2526
import modelengine.fitframework.annotation.Component;
2627

2728
import java.util.List;
29+
import java.util.Locale;
2830

2931
/**
3032
* 应用业务分类对外接口。
@@ -58,7 +60,8 @@ public AppTypeController(Authenticator authenticator, AppTypeService appTypeServ
5860
@GetMapping(description = "查询所有应用业务分类")
5961
public Rsp<List<AppTypeDto>> queryAll(HttpClassicServerRequest request,
6062
@PathVariable("tenant_id") String tenantId) {
61-
return Rsp.ok(this.appTypeService.queryAll(tenantId));
63+
Locale locale = LocaleUtil.getLocale();
64+
return Rsp.ok(this.appTypeService.queryAll(tenantId, locale.getLanguage()));
6265
}
6366

6467
/**

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/dto/AppTypeDto.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ public class AppTypeDto {
2828

2929
@Property(description = "名字")
3030
private String name;
31+
32+
@Property(description = "语言类型")
33+
private String language;
3134
}

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/mapper/AppBuilderAppTypeMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public interface AppBuilderAppTypeMapper {
2121
* 查询所有分类信息。
2222
*
2323
* @param tenantId 表示租户唯一标识的 {@link String}。
24+
* @param language 表示分类的语音类型的 {@link String}。
2425
* @return 表示分类列表的 {@link List}{@code <}{@link AppBuilderAppTypePo}{@code >}。
2526
*/
26-
List<AppBuilderAppTypePo> queryAll(String tenantId);
27+
List<AppBuilderAppTypePo> queryAll(String tenantId, String language);
2728

2829
/**
2930
* 插入一条分类信息。

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/po/AppBuilderAppTypePo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ public class AppBuilderAppTypePo {
3434
private String tenantId;
3535
private LocalDateTime createAt;
3636
private LocalDateTime updateAt;
37+
private String language;
3738
}

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/service/AppTypeService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public interface AppTypeService {
2121
* 查询租户下所有分类定义信息。
2222
*
2323
* @param tenantId 表示租户唯一标识的 {@link String}。
24+
* @param language 表示分类的语音类型的 {@link String}。
2425
* @return 表示分类定义信息列表的 {@link List}{@code <}{@link AppTypeDto}{@code >}。
2526
*/
26-
List<AppTypeDto> queryAll(String tenantId);
27+
List<AppTypeDto> queryAll(String tenantId, String language);
2728

2829
/**
2930
* 根据应用分类唯一标识和租户唯一标识查询分类信息。

app-builder/jane/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/service/impl/AppTypeServiceImpl.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public AppTypeServiceImpl(AppBuilderAppTypeMapper appBuilderAppTypeMapper) {
3737
}
3838

3939
@Override
40-
public List<AppTypeDto> queryAll(String tenantId) {
41-
return this.appBuilderAppTypeMapper.queryAll(tenantId)
40+
public List<AppTypeDto> queryAll(String tenantId, String language) {
41+
return this.appBuilderAppTypeMapper.queryAll(tenantId, language)
4242
.stream()
4343
.map(this::deserialize)
4444
.collect(Collectors.toList());
@@ -73,15 +73,16 @@ public void update(AppTypeDto dto, String tenantId) {
7373
private AppBuilderAppTypePo serialize(AppTypeDto dto, String tenantId) {
7474
LocalDateTime now = LocalDateTime.now();
7575
return AppBuilderAppTypePo.builder()
76-
.id(dto.getId())
77-
.name(dto.getName())
78-
.tenantId(tenantId)
79-
.createAt(now)
80-
.updateAt(now)
81-
.build();
76+
.id(dto.getId())
77+
.name(dto.getName())
78+
.tenantId(tenantId)
79+
.createAt(now)
80+
.updateAt(now)
81+
.language(dto.getLanguage())
82+
.build();
8283
}
8384

8485
private AppTypeDto deserialize(AppBuilderAppTypePo po) {
85-
return AppTypeDto.builder().id(po.getId()).name(po.getName()).build();
86+
return AppTypeDto.builder().id(po.getId()).name(po.getName()).language(po.getLanguage()).build();
8687
}
8788
}

app-builder/jane/plugins/aipp-plugin/src/main/resources/mapper/AppBuilderAppTypeMapper.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
</resultMap>
1111

1212
<select id="queryAll" resultType="modelengine.fit.jober.aipp.po.AppBuilderAppTypePo" resultMap="ResultMap">
13-
SELECT id, name, tenant_id, create_at, update_at
13+
SELECT id, name, tenant_id, create_at, update_at, language
1414
FROM app_builder_app_type
15-
WHERE tenant_id = #{tenantId}
15+
WHERE tenant_id = #{tenantId} and language = #{language}
1616
ORDER BY create_at ASC
1717
</select>
1818

1919
<insert id="insert" parameterType="modelengine.fit.jober.aipp.po.AppBuilderAppTypePo">
20-
INSERT INTO app_builder_app_type (id, name, tenant_id, create_at, update_at)
21-
VALUES (#{id}, #{name}, #{tenantId}, #{createAt}, #{updateAt})
20+
INSERT INTO app_builder_app_type (id, name, tenant_id, create_at, update_at, language)
21+
VALUES (#{id}, #{name}, #{tenantId}, #{createAt}, #{updateAt}, #{language})
2222
</insert>
2323

2424
<update id="update" parameterType="modelengine.fit.jober.aipp.po.AppBuilderAppTypePo">
@@ -35,7 +35,7 @@
3535
</delete>
3636

3737
<select id="query" resultType="modelengine.fit.jober.aipp.po.AppBuilderAppTypePo" resultMap="ResultMap">
38-
SELECT id, name, tenant_id, create_at, update_at
38+
SELECT id, name, tenant_id, create_at, update_at, language
3939
FROM app_builder_app_type
4040
WHERE id = #{id}
4141
</select>

app-builder/jane/plugins/aipp-plugin/src/main/resources/sql/data/appbuilder_insert.sql

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,22 @@ VALUES ('c6a2d574ccfb46754hb9de3ac88ef199', 'form_property_opening_content', 'zh
175175

176176
INSERT INTO aipp_system_config(config_key, config_value, config_group, config_parent) VALUES ('system', '{"template": "You ara a prompt generator, Your job is to generate prompt from the input of the user.\n\nThe Prompt must follow the style of the example below:\n\n###\ninput:\n生活助手\n\noutput:\n角色:你是一个智能生活助手。\n背景:作为一款集成多种智能功能的应用程序,你需要熟悉各种智能家居设备、日程安排、健康数据等相关知识。\n技能:智能家居控制照明、温控、安防、日程管理(提醒、安排等)、健康监测(睡眠、运行、饮食等)、信息查询、语音交互等。\n目标:为用户提供便捷。\n限制:你可以访问用户的智能家居设备、日历、健康数据等相关信息,并根据需要进行协作和响应。\n###\n\n**DO NOT GENERATE ANY OTHER CONTENT EXCEPT OF THE PROMPT TEMPLATE**\n\ninput: {{input}}"}', 'template', NULL) ON CONFLICT (config_group, config_key) DO NOTHING;
177177

178-
INSERT INTO "app_builder_app_type" VALUES ('4db152b24f94473ab683b1acbfe3c865', '通用', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:26:11.275326', '2025-01-16 17:26:11.275326') ON CONFLICT (id) DO NOTHING;
179-
INSERT INTO "app_builder_app_type" VALUES ('ad7fca4851394495a90723eb6bcd6141', '文章写作', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:26:53.880531', '2025-01-16 17:26:53.880531') ON CONFLICT (id) DO NOTHING;
180-
INSERT INTO "app_builder_app_type" VALUES ('099201eaee2346a7bffd76bbdbfb0c7e', '编程开发', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:02.607163', '2025-01-16 17:27:02.607163') ON CONFLICT (id) DO NOTHING;
181-
INSERT INTO "app_builder_app_type" VALUES ('19301209cff644e0bed7aede966226fa', '金融问数', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:15.121579', '2025-01-16 17:27:15.121579') ON CONFLICT (id) DO NOTHING;
182-
INSERT INTO "app_builder_app_type" VALUES ('dadb32e11d0f49c8b3b2b3b78f32adcb', '知识问答', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:24.408541', '2025-01-16 17:27:24.408541') ON CONFLICT (id) DO NOTHING;
183-
INSERT INTO "app_builder_app_type" VALUES ('bfce7a4f00ea464ca85b1bd691ffe774', '数字人', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:31.439755', '2025-01-16 17:27:31.439755') ON CONFLICT (id) DO NOTHING;
184-
INSERT INTO "app_builder_app_type" VALUES ('b653edb7eb5a49be91abcd2c5877c6ad', '办公效率', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:40.941004', '2025-01-16 17:27:40.941004') ON CONFLICT (id) DO NOTHING;
185-
INSERT INTO "app_builder_app_type" VALUES ('6cca24416a05436390e0a96712a4294e', '企业管理', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:50.566101', '2025-01-16 17:27:50.566101') ON CONFLICT (id) DO NOTHING;
178+
INSERT INTO "app_builder_app_type" VALUES ('4db152b24f94473ab683b1acbfe3c865', '通用', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:26:11.275326', '2025-01-16 17:26:11.275326', 'zh') ON CONFLICT (id) DO NOTHING;
179+
INSERT INTO "app_builder_app_type" VALUES ('ad7fca4851394495a90723eb6bcd6141', '文章写作', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:26:53.880531', '2025-01-16 17:26:53.880531', 'zh') ON CONFLICT (id) DO NOTHING;
180+
INSERT INTO "app_builder_app_type" VALUES ('099201eaee2346a7bffd76bbdbfb0c7e', '编程开发', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:02.607163', '2025-01-16 17:27:02.607163', 'zh') ON CONFLICT (id) DO NOTHING;
181+
INSERT INTO "app_builder_app_type" VALUES ('19301209cff644e0bed7aede966226fa', '金融问数', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:15.121579', '2025-01-16 17:27:15.121579', 'zh') ON CONFLICT (id) DO NOTHING;
182+
INSERT INTO "app_builder_app_type" VALUES ('dadb32e11d0f49c8b3b2b3b78f32adcb', '知识问答', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:24.408541', '2025-01-16 17:27:24.408541', 'zh') ON CONFLICT (id) DO NOTHING;
183+
INSERT INTO "app_builder_app_type" VALUES ('bfce7a4f00ea464ca85b1bd691ffe774', '数字人', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:31.439755', '2025-01-16 17:27:31.439755', 'zh') ON CONFLICT (id) DO NOTHING;
184+
INSERT INTO "app_builder_app_type" VALUES ('b653edb7eb5a49be91abcd2c5877c6ad', '办公效率', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:40.941004', '2025-01-16 17:27:40.941004', 'zh') ON CONFLICT (id) DO NOTHING;
185+
INSERT INTO "app_builder_app_type" VALUES ('6cca24416a05436390e0a96712a4294e', '企业管理', '31f20efc7e0848deab6a6bc10fc3021e', '2025-01-16 17:27:50.566101', '2025-01-16 17:27:50.566101', 'zh') ON CONFLICT (id) DO NOTHING;
186+
INSERT INTO "app_builder_app_type" VALUES ('38a3ac7fed2143f098494cd2cc38ad9b', 'universal', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:32:37.029701', '2025-06-14 07:32:37.029701', 'en') ON CONFLICT (id) DO NOTHING;
187+
INSERT INTO "app_builder_app_type" VALUES ('0abbaea72d944569b9a2b79b14c21f9f', 'article writing', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:33:08.523671', '2025-06-14 07:33:08.523671', 'en') ON CONFLICT (id) DO NOTHING;
188+
INSERT INTO "app_builder_app_type" VALUES ('8659ce374fcf4857b166e8550691de82', 'programming development', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:33:18.998468', '2025-06-14 07:33:18.998468', 'en') ON CONFLICT (id) DO NOTHING;
189+
INSERT INTO "app_builder_app_type" VALUES ('33125c0159d54a868615f8639f7de8ff', 'financial question', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:33:38.937197', '2025-06-14 07:33:38.937197', 'en') ON CONFLICT (id) DO NOTHING;
190+
INSERT INTO "app_builder_app_type" VALUES ('99887c230e56443297fa18c00a2abde1', 'knowledge quiz', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:34:54.924854', '2025-06-14 07:34:54.924854', 'en') ON CONFLICT (id) DO NOTHING;
191+
INSERT INTO "app_builder_app_type" VALUES ('581811d70c044a71ba162d1c343ab6b8', 'digital human', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:35:07.338292', '2025-06-14 07:35:07.338292', 'en') ON CONFLICT (id) DO NOTHING;
192+
INSERT INTO "app_builder_app_type" VALUES ('3220fee69abc480e9fad467ae722d4a6', 'office efficiency', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:35:17.995892', '2025-06-14 07:35:17.995892', 'en') ON CONFLICT (id) DO NOTHING;
193+
INSERT INTO "app_builder_app_type" VALUES ('0ee3c200713c40c9a8c2cc09c157ff5c', 'enterprise management', '31f20efc7e0848deab6a6bc10fc3021e', '2025-06-14 07:35:31.56825', '2025-06-14 07:35:31.56825', 'en') ON CONFLICT (id) DO NOTHING;
186194

187195
INSERT INTO "public"."i18n" ("id", "key", "language", "value") VALUES ('c6a2d574ccfb4687a8b9de3ac88ef1e3', 'semantic_search', 'en', 'Semantic search') ON CONFLICT (id) DO NOTHING;
188196
INSERT INTO "public"."i18n" ("id", "key", "language", "value") VALUES ('c6a2d574ccfb4687a8b9de3ac88ef1e2', 'semantic_search', 'zh', '语义检索') ON CONFLICT (id) DO NOTHING;

app-builder/jane/plugins/aipp-plugin/src/main/resources/sql/schema/create_tables/appbuilder_create.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ create table if not exists app_builder_app_type
291291
tenant_id varchar(255) not null,
292292
create_at timestamp not null default current_timestamp,
293293
update_at timestamp not null default current_timestamp,
294+
language varchar(64) NULL,
294295
CONSTRAINT "app_builder_app_type_name_tenant_id_key" UNIQUE ("name", "tenant_id")
295296
);
296297

app-builder/jane/plugins/aipp-plugin/src/test/java/modelengine/fit/jober/aipp/service/impl/AppTypeServiceImplTest.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ void shouldCallMapperWhenQueryAll() {
4545
List<AppBuilderAppTypePo> expectResult = new ArrayList<>();
4646
String tenantId = "tenant";
4747
AppBuilderAppTypePo expectType = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
48-
LocalDateTime.now());
48+
LocalDateTime.now(), "zh");
4949
expectResult.add(expectType);
50-
Mockito.when(this.appBuilderAppTypeMapper.queryAll(tenantId)).thenReturn(expectResult);
50+
Mockito.when(this.appBuilderAppTypeMapper.queryAll(Mockito.eq(tenantId), Mockito.eq("zh")))
51+
.thenReturn(expectResult);
5152

52-
List<AppTypeDto> result = this.appTypeService.queryAll(tenantId);
53+
List<AppTypeDto> result = this.appTypeService.queryAll(tenantId, "zh" );
5354

5455
Assertions.assertEquals(expectResult.size(), result.size());
5556
Assertions.assertEquals(expectType.getId(), result.get(0).getId());
@@ -60,7 +61,7 @@ void shouldCallMapperWhenQueryAll() {
6061
void shouldCallMapperWhenQueryById() {
6162
String tenantId = "tenant";
6263
AppBuilderAppTypePo expectPo = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
63-
LocalDateTime.now());
64+
LocalDateTime.now(), "zh");
6465
Mockito.when(this.appBuilderAppTypeMapper.query(expectPo.getId(), tenantId)).thenReturn(expectPo);
6566

6667
AppTypeDto result = this.appTypeService.query(expectPo.getId(), tenantId);
@@ -73,14 +74,16 @@ void shouldCallMapperWhenQueryById() {
7374
void shouldCallMapperWhenAddGivenTypeWithId() {
7475
String tenantId = "tenant";
7576
AppBuilderAppTypePo expectPo = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
76-
LocalDateTime.now());
77+
LocalDateTime.now(), "zh");
7778
Mockito.doNothing()
7879
.when(this.appBuilderAppTypeMapper)
7980
.insert(Mockito.argThat(
8081
po -> po.getId().equals(expectPo.getId()) && po.getName().equals(expectPo.getName())
8182
&& po.getTenantId().equals(expectPo.getTenantId())));
8283

83-
AppTypeDto result = this.appTypeService.add(new AppTypeDto(expectPo.getId(), expectPo.getName()), tenantId);
84+
AppTypeDto result =
85+
this.appTypeService.add(new AppTypeDto(expectPo.getId(), expectPo.getName(), expectPo.getLanguage()),
86+
tenantId);
8487

8588
Mockito.verify(this.appBuilderAppTypeMapper, Mockito.times(1)).insert(Mockito.any(AppBuilderAppTypePo.class));
8689
Assertions.assertEquals(expectPo.getId(), result.getId());
@@ -91,14 +94,15 @@ void shouldCallMapperWhenAddGivenTypeWithId() {
9194
void shouldReturnNewIdWhenAddGivenTypeWithoutId() {
9295
String tenantId = "tenant";
9396
AppBuilderAppTypePo expectPo = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
94-
LocalDateTime.now());
97+
LocalDateTime.now(), "zh");
9598
Mockito.doNothing()
9699
.when(this.appBuilderAppTypeMapper)
97100
.insert(Mockito.argThat(
98101
po -> !po.getId().isEmpty() && po.getName().equals(expectPo.getName())
99102
&& po.getTenantId().equals(expectPo.getTenantId())));
100103

101-
AppTypeDto result = this.appTypeService.add(new AppTypeDto("", expectPo.getName()), tenantId);
104+
AppTypeDto result =
105+
this.appTypeService.add(new AppTypeDto("", expectPo.getName(), expectPo.getLanguage()), tenantId);
102106

103107
Mockito.verify(this.appBuilderAppTypeMapper, Mockito.times(1)).insert(Mockito.any(AppBuilderAppTypePo.class));
104108
Assertions.assertFalse(result.getId().isEmpty());
@@ -109,7 +113,7 @@ void shouldReturnNewIdWhenAddGivenTypeWithoutId() {
109113
void shouldCallMapperWhenDeleteGivenTypeId() {
110114
String tenantId = "tenant";
111115
AppBuilderAppTypePo expectPo = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
112-
LocalDateTime.now());
116+
LocalDateTime.now(), "zh");
113117
Mockito.doNothing().when(this.appBuilderAppTypeMapper).delete(expectPo.getId(), tenantId);
114118

115119
this.appTypeService.delete(expectPo.getId(), tenantId);
@@ -121,14 +125,15 @@ void shouldCallMapperWhenDeleteGivenTypeId() {
121125
void shouldCallMapperWhenUpdateGivenTypeInfo() {
122126
String tenantId = "tenant";
123127
AppBuilderAppTypePo expectPo = new AppBuilderAppTypePo("1", "type1", tenantId, LocalDateTime.now(),
124-
LocalDateTime.now());
128+
LocalDateTime.now(), "zh");
125129
Mockito.doNothing()
126130
.when(this.appBuilderAppTypeMapper)
127131
.update(Mockito.argThat(
128132
po -> po.getId().equals(expectPo.getId()) && po.getName().equals(expectPo.getName())
129133
&& po.getTenantId().equals(expectPo.getTenantId())));
130134

131-
this.appTypeService.update(new AppTypeDto(expectPo.getId(), expectPo.getName()), tenantId);
135+
this.appTypeService.update(new AppTypeDto(expectPo.getId(), expectPo.getName(), expectPo.getLanguage()),
136+
tenantId);
132137

133138
Mockito.verify(this.appBuilderAppTypeMapper, Mockito.times(1)).update(Mockito.any(AppBuilderAppTypePo.class));
134139
}

0 commit comments

Comments
 (0)