Skip to content

Commit bf2226e

Browse files
author
wuayee
committed
[appBuilder] 实现分域功能
1 parent b0e18b2 commit bf2226e

File tree

96 files changed

+1620
-168
lines changed

Some content is hidden

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

96 files changed

+1620
-168
lines changed

app-builder/plugins/aipp-custom-model-center/src/main/resources/sql/data/tr_t_model_import.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('f76205df-
1717
INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('77ee3e02-5870-4338-a8be-52c8ed42f3c7', 'MODEL') ON CONFLICT ("tool_unique_name", "name") DO NOTHING;
1818
INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('16816279-411b-48e1-b754-191abd61dcd0', 'MODEL') ON CONFLICT ("tool_unique_name", "name") DO NOTHING;
1919

20-
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon") VALUES (0, 0, '切换默认模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', 'f76205df-1814-49b9-a473-c03ee99770b7', '', NULL) ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
21-
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon") VALUES (0, 0, '删除模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', 'ff0a4b59-0be7-436f-8931-6a599ed9f8f3', '', NULL) ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
22-
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon") VALUES (0, 0, '添加模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '77ee3e02-5870-4338-a8be-52c8ed42f3c7', '', NULL) ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
23-
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon") VALUES (0, 0, '获取用户模型列表', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '16816279-411b-48e1-b754-191abd61dcd0', '', NULL) ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
20+
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon", "user_group_id") VALUES (0, 0, '切换默认模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', 'f76205df-1814-49b9-a473-c03ee99770b7', '', NULL, '*') ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
21+
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon", "user_group_id") VALUES (0, 0, '删除模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', 'ff0a4b59-0be7-436f-8931-6a599ed9f8f3', '', NULL, '*') ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
22+
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon", "user_group_id") VALUES (0, 0, '添加模型', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '77ee3e02-5870-4338-a8be-52c8ed42f3c7', '', NULL, '*') ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
23+
INSERT INTO "public"."store_plugin_tool" ("like_count", "download_count", "tool_name", "plugin_id", "tool_unique_name", "source", "icon", "user_group_id") VALUES (0, 0, '获取用户模型列表', 'f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '16816279-411b-48e1-b754-191abd61dcd0', '', NULL, '*') ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
2424

25-
INSERT INTO "public"."store_plugin" ("plugin_id", "plugin_name", "extension", "deploy_status", "is_builtin", "source", "icon") VALUES ('f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '用戶查询模型工具', '{"uniqueness.groupId":"user-model-edit-groupId","pluginFullName":"aipp-custom-model-center-1.0.0-SNAPSHOT_1744769471992.jar","checksum":"77679d190769b46a8da7e2c08a1f2ce2680647e430514e7da1d39be3f3d17925","name":"用戶查询模型工具","description":"这是一个用戶查询模型工具","uniqueness.artifactId":"user-model-edit-artifactId","type":"java"}', 'DEPLOYED', TRUE, '', NULL) ON CONFLICT ("plugin_id") DO NOTHING;
25+
INSERT INTO "public"."store_plugin" ("plugin_id", "plugin_name", "extension", "deploy_status", "is_builtin", "source", "icon", "user_group_id") VALUES ('f231f908d0f0959acbc1df7b2f4b8f76b05219e3fa82fcb715def9f8858139e5', '用戶查询模型工具', '{"uniqueness.groupId":"user-model-edit-groupId","pluginFullName":"aipp-custom-model-center-1.0.0-SNAPSHOT_1744769471992.jar","checksum":"77679d190769b46a8da7e2c08a1f2ce2680647e430514e7da1d39be3f3d17925","name":"用戶查询模型工具","description":"这是一个用戶查询模型工具","uniqueness.artifactId":"user-model-edit-artifactId","type":"java"}', 'DEPLOYED', TRUE, '', NULL, '*') ON CONFLICT ("plugin_id") DO NOTHING;
2626

27-
INSERT INTO "public"."app_builder_form" ("id", "name", "tenant_id", "appearance", "type", "create_by", "create_at", "update_by", "update_at", "is_deleted", "form_suite_id", "version") VALUES ('1568509614c245a39ce53bda9c3c2ec1', '模型管理表单', '31f20efc7e0848deab6a6bc10fc3021e', '{"imgUrl": "smart_form/6befc536-7e6d-48b5-8dcb-1c4d04ca4e92/form.png", "schema": {"name": "模型管理表单", "return": {"type": "object", "required": ["action", "info"], "properties": {"info": {"type": "object", "required": ["modelName", "modelId", "baseUrl", "isDefault", "userId", "apiKey"], "properties": {"apiKey": {"type": "string"}, "userId": {"type": "string"}, "baseUrl": {"type": "string"}, "modelId": {"type": "string"}, "isDefault": {"type": "integer"}, "modelName": {"type": "string"}, "type": {"type": "string"}}}, "action": {"enum": ["add", "delete", "switch", "quit"], "type": "string"}}}, "parameters": {"type": "object", "required": ["models"], "properties": {"models": {"type": "array", "items": {"type": "object", "required": ["modelId", "isDefault", "userId"], "properties": {"userId": {"type": "string"}, "baseUrl": {"type": "string"}, "modelId": {"type": "string"}, "createdAt": {"type": "string"}, "isDefault": {"type": "integer"}, "modelName": {"type": "string"}, "type": {"type": "string"}}}}}}}, "fileName": "模型管理表单.zip", "fileSize": 352510, "fileUuid": "7e9db4c01d8f482596fc1ddc78625496", "iframeUrl": "smart_form/6befc536-7e6d-48b5-8dcb-1c4d04ca4e92/build/index.html", "description": "这是一个模型管理表单"}', 'runtime', 'system', '2025-04-18 12:09:28.732006', 'system', '2025-04-18 12:09:28.73202', 0, '07b7ebd306944de683c2d060944da579', '1.0.0') ON CONFLICT ("id") DO NOTHING;
27+
INSERT INTO "public"."app_builder_form" ("id", "name", "tenant_id", "appearance", "type", "create_by", "create_at", "update_by", "update_at", "is_deleted", "form_suite_id", "version", "user_group_id") VALUES ('1568509614c245a39ce53bda9c3c2ec1', '模型管理表单', '31f20efc7e0848deab6a6bc10fc3021e', '{"imgUrl": "smart_form/6befc536-7e6d-48b5-8dcb-1c4d04ca4e92/form.png", "schema": {"name": "模型管理表单", "return": {"type": "object", "required": ["action", "info"], "properties": {"info": {"type": "object", "required": ["modelName", "modelId", "baseUrl", "isDefault", "userId", "apiKey"], "properties": {"apiKey": {"type": "string"}, "userId": {"type": "string"}, "baseUrl": {"type": "string"}, "modelId": {"type": "string"}, "isDefault": {"type": "integer"}, "modelName": {"type": "string"}, "type": {"type": "string"}}}, "action": {"enum": ["add", "delete", "switch", "quit"], "type": "string"}}}, "parameters": {"type": "object", "required": ["models"], "properties": {"models": {"type": "array", "items": {"type": "object", "required": ["modelId", "isDefault", "userId"], "properties": {"userId": {"type": "string"}, "baseUrl": {"type": "string"}, "modelId": {"type": "string"}, "createdAt": {"type": "string"}, "isDefault": {"type": "integer"}, "modelName": {"type": "string"}, "type": {"type": "string"}}}}}}}, "fileName": "模型管理表单.zip", "fileSize": 352510, "fileUuid": "7e9db4c01d8f482596fc1ddc78625496", "iframeUrl": "smart_form/6befc536-7e6d-48b5-8dcb-1c4d04ca4e92/build/index.html", "description": "这是一个模型管理表单"}', 'runtime', 'system', '2025-04-18 12:09:28.732006', 'system', '2025-04-18 12:09:28.73202', 0, '07b7ebd306944de683c2d060944da579', '1.0.0', '*') ON CONFLICT ("id") DO NOTHING;
2828

29-
INSERT INTO "public"."app_builder_app" ("id", "name", "create_by", "create_at", "update_by", "update_at", "config_id", "flow_graph_id", "tenant_id", "type", "version", "attributes", "state", "app_built_type", "app_category", "collection_usr_cnt", "is_deleted", "path", "app_type", "app_suite_id", "is_active", "status", "unique_name", "publish_at", "app_id") VALUES ('cec6bfe7cb3a444f8a26a97ea513e501', '模型配置应用', 'system', '2025-07-25 03:33:56.014633', 'system', '2025-07-25 03:34:46.694847', '99bc4eda890041878bc0e4fe13114956', 'df3c7df760964d08b092f7c9d0eb9513', '31f20efc7e0848deab6a6bc10fc3021e', 'app', '1.0.0', '{"icon": "", "app_type": "b653edb7eb5a49be91abcd2c5877c6ad", "greeting": "", "store_id": "7a76cbd2-881d-469b-b2df-76abed7d0b61", "is_update": true, "description": "当你想要配置模型的时候,请使用我!", "latest_version": "1.0.0", "publishedUpdateLog": "", "publishedDescription": ""}', 'active', 'workflow', 'chatbot', 0, 0, 'P920UNZY2JkYoWhl', 'b653edb7eb5a49be91abcd2c5877c6ad', '0b4fe5a430104edfbe0dc6cff0ebea19', 't', 'published', '7a76cbd2-881d-469b-b2df-76abed7d0b61', '2025-07-25 03:34:46.69485', 'cec6bfe7cb3a444f8a26a97ea513e501') ON CONFLICT (id) DO NOTHING;
29+
INSERT INTO "public"."app_builder_app" ("id", "name", "create_by", "create_at", "update_by", "update_at", "config_id", "flow_graph_id", "tenant_id", "type", "version", "attributes", "state", "app_built_type", "app_category", "collection_usr_cnt", "is_deleted", "path", "app_type", "app_suite_id", "is_active", "status", "unique_name", "publish_at", "app_id", "user_group_id") VALUES ('cec6bfe7cb3a444f8a26a97ea513e501', '模型配置应用', 'system', '2025-07-25 03:33:56.014633', 'system', '2025-07-25 03:34:46.694847', '99bc4eda890041878bc0e4fe13114956', 'df3c7df760964d08b092f7c9d0eb9513', '31f20efc7e0848deab6a6bc10fc3021e', 'app', '1.0.0', '{"icon": "", "app_type": "b653edb7eb5a49be91abcd2c5877c6ad", "greeting": "", "store_id": "7a76cbd2-881d-469b-b2df-76abed7d0b61", "is_update": true, "description": "当你想要配置模型的时候,请使用我!", "latest_version": "1.0.0", "publishedUpdateLog": "", "publishedDescription": ""}', 'active', 'workflow', 'chatbot', 0, 0, 'P920UNZY2JkYoWhl', 'b653edb7eb5a49be91abcd2c5877c6ad', '0b4fe5a430104edfbe0dc6cff0ebea19', 't', 'published', '7a76cbd2-881d-469b-b2df-76abed7d0b61', '2025-07-25 03:34:46.69485', 'cec6bfe7cb3a444f8a26a97ea513e501', '*') ON CONFLICT (id) DO NOTHING;
3030

3131
INSERT INTO "public"."app_builder_config" ("id", "form_id", "app_id", "tenant_id", "create_by", "create_at", "update_by", "update_at", "is_deleted") VALUES ('99bc4eda890041878bc0e4fe13114956', 'b8986770a6ffef44bbf2a9f26d6fc1be', 'cec6bfe7cb3a444f8a26a97ea513e501', '31f20efc7e0848deab6a6bc10fc3021e', 'system', '2025-04-18 11:54:33.515505', 'system', '2025-04-18 12:12:12.847078', 0) ON CONFLICT (id) DO NOTHING;
3232

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>modelengine.fit.jade</groupId>
8+
<artifactId>app-builder-plugin-parent</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<groupId>modelengine.fit.jade.plugin</groupId>
13+
<artifactId>aipp-domain-division</artifactId>
14+
15+
<dependencies>
16+
<!-- FIT -->
17+
<dependency>
18+
<groupId>org.fitframework</groupId>
19+
<artifactId>fit-api</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.fitframework.service</groupId>
23+
<artifactId>fit-http-classic</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.fitframework</groupId>
27+
<artifactId>fit-util</artifactId>
28+
</dependency>
29+
30+
<!-- Services -->
31+
<dependency>
32+
<groupId>modelengine.jade.service</groupId>
33+
<artifactId>aipp-domain-division-service</artifactId>
34+
<version>1.0.0-SNAPSHOT</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>modelengine.fit.jade.service</groupId>
38+
<artifactId>authentication-service</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>modelengine.fit.jade.service</groupId>
42+
<artifactId>common-service</artifactId>
43+
<version>1.0.0-SNAPSHOT</version>
44+
</dependency>
45+
46+
<!-- Third-party -->
47+
<dependency>
48+
<groupId>org.projectlombok</groupId>
49+
<artifactId>lombok</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.fitframework.integration</groupId>
53+
<artifactId>fit-mybatis</artifactId>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.postgresql</groupId>
57+
<artifactId>postgresql</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.mybatis</groupId>
61+
<artifactId>mybatis</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.alibaba</groupId>
65+
<artifactId>druid</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.fitframework.integration</groupId>
69+
<artifactId>fit-druid</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>com.fasterxml.jackson.core</groupId>
73+
<artifactId>jackson-databind</artifactId>
74+
</dependency>
75+
76+
<!-- Test -->
77+
<dependency>
78+
<groupId>org.junit.jupiter</groupId>
79+
<artifactId>junit-jupiter</artifactId>
80+
<scope>test</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.mockito</groupId>
84+
<artifactId>mockito-inline</artifactId>
85+
<scope>test</scope>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.assertj</groupId>
89+
<artifactId>assertj-core</artifactId>
90+
<scope>test</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.fitframework</groupId>
94+
<artifactId>fit-test-framework</artifactId>
95+
<scope>test</scope>
96+
</dependency>
97+
<dependency>
98+
<groupId>com.h2database</groupId>
99+
<artifactId>h2</artifactId>
100+
<scope>test</scope>
101+
</dependency>
102+
</dependencies>
103+
104+
<build>
105+
<plugins>
106+
<plugin>
107+
<groupId>org.fitframework</groupId>
108+
<artifactId>fit-build-maven-plugin</artifactId>
109+
<version>${fit.version}</version>
110+
<configuration>
111+
<category>user</category>
112+
<level>3</level>
113+
</configuration>
114+
<executions>
115+
<execution>
116+
<id>build-plugin</id>
117+
<goals>
118+
<goal>build-plugin</goal>
119+
</goals>
120+
</execution>
121+
<execution>
122+
<id>package-plugin</id>
123+
<goals>
124+
<goal>package-plugin</goal>
125+
</goals>
126+
</execution>
127+
</executions>
128+
</plugin>
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-antrun-plugin</artifactId>
132+
<version>${maven.antrun.version}</version>
133+
<executions>
134+
<execution>
135+
<phase>install</phase>
136+
<configuration>
137+
<target>
138+
<copy file="${project.build.directory}/${project.build.finalName}.jar"
139+
todir="../../../build/plugins"/>
140+
</target>
141+
</configuration>
142+
<goals>
143+
<goal>run</goal>
144+
</goals>
145+
</execution>
146+
</executions>
147+
</plugin>
148+
</plugins>
149+
</build>
150+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
7+
package modelengine.fit.jade.aipp.domain.division.aop;
8+
9+
import modelengine.fit.http.client.HttpClassicClientFactory;
10+
import modelengine.fit.jade.aipp.domain.division.UserGroup;
11+
import modelengine.fit.jade.aipp.domain.division.entity.UserInfo;
12+
import modelengine.fit.jade.aipp.domain.division.entity.UserInfoHolder;
13+
import modelengine.fitframework.annotation.Component;
14+
import modelengine.fitframework.annotation.Scope;
15+
import modelengine.fitframework.annotation.Value;
16+
import modelengine.fitframework.aop.JoinPoint;
17+
import modelengine.fitframework.aop.annotation.After;
18+
import modelengine.fitframework.aop.annotation.AfterThrowing;
19+
import modelengine.fitframework.aop.annotation.Aspect;
20+
import modelengine.fitframework.aop.annotation.Before;
21+
import modelengine.fitframework.util.StringUtils;
22+
23+
/**
24+
* 表示创建资源的切面
25+
*
26+
* @author 邬涨财
27+
* @since 2025-08-12
28+
*/
29+
@Aspect(scope = Scope.GLOBAL)
30+
@Component
31+
public class CreateSourceAspect extends SourceAspect {
32+
private final String allGroupId;
33+
private final String allGroupAliasId;
34+
private final boolean isEnableDomainDivision;
35+
36+
public CreateSourceAspect(@Value("${domain-division.all-group.id}") final String allGroupId,
37+
@Value("${domain-division.all-group.alias.id}") final String allGroupAliasId,
38+
HttpClassicClientFactory httpClientFactory,
39+
@Value("${domain-division.all-group.host}") final String allGroupHost,
40+
@Value("${domain-division.all-group.path}") final String allGroupPath,
41+
@Value("${domain-division.isEnable}") boolean isEnableDomainDivision) {
42+
super(httpClientFactory, allGroupHost + allGroupPath);
43+
this.allGroupId = allGroupId;
44+
this.allGroupAliasId = allGroupAliasId;
45+
this.isEnableDomainDivision = isEnableDomainDivision;
46+
}
47+
48+
private UserInfo buildUserInfo(String username, String userGroupId) {
49+
return UserInfo.builder().username(username).userGroupId(userGroupId).build();
50+
}
51+
52+
/**
53+
* 资源创建前的切面处理。
54+
*
55+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
56+
*/
57+
@Before("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
58+
public void beforeCreate(JoinPoint joinPoint) {
59+
if (!this.isEnableDomainDivision) {
60+
return;
61+
}
62+
String username = this.getUserName();
63+
UserGroup userGroup = this.getUserGroup(username);
64+
String id = userGroup.getId();
65+
if (StringUtils.equals(this.allGroupAliasId, id)) {
66+
id = this.allGroupId;
67+
}
68+
UserInfo userInfo = this.buildUserInfo(username, id);
69+
UserInfoHolder.set(userInfo);
70+
}
71+
72+
/**
73+
* 资源创建后的切面处理。
74+
*
75+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
76+
*/
77+
@After("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
78+
public void afterCreate(JoinPoint joinPoint) {
79+
this.clear();
80+
}
81+
82+
/**
83+
* 资源创建出现异常后的切面处理。
84+
*
85+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
86+
*/
87+
@AfterThrowing("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
88+
public void afterCreateThrowing(JoinPoint joinPoint) {
89+
this.clear();
90+
}
91+
}

0 commit comments

Comments
 (0)