Skip to content

Commit 5e73437

Browse files
wuayeewuayeexili9459lixin_33
authored
[app-builder] 实现分域功能 (#422)
* [[appBuilder] 实现分域功能 * [appBuilder] 分域和游客模式的适配 * [app-builder] 分域pr检视意见修改 --------- Co-authored-by: wuayee <[email protected]> Co-authored-by: wuayee <[email protected]> Co-authored-by: lixin_33 <[email protected]>
1 parent 1321fe7 commit 5e73437

File tree

176 files changed

+2892
-1568
lines changed

Some content is hidden

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

176 files changed

+2892
-1568
lines changed

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

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.
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.host}") final String allGroupHost,
40+
@Value("${domain-division.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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
22+
import java.util.List;
23+
24+
/**
25+
* 表示获取资源的切面
26+
*
27+
* @author 邬涨财
28+
* @since 2025-08-12
29+
*/
30+
@Aspect(scope = Scope.GLOBAL)
31+
@Component
32+
public class GetSourceAspect extends SourceAspect {
33+
private final List<String> allGroupUsers;
34+
private final boolean isEnableDomainDivision;
35+
36+
public GetSourceAspect(@Value("${domain-division.all-group.users}") final List<String> allGroupUsers,
37+
HttpClassicClientFactory httpClientFactory,
38+
@Value("${domain-division.host}") final String allGroupHost,
39+
@Value("${domain-division.path}") final String allGroupPath,
40+
@Value("${domain-division.isEnable}") boolean isEnableDomainDivision) {
41+
super(httpClientFactory, allGroupHost + allGroupPath);
42+
this.allGroupUsers = allGroupUsers;
43+
this.isEnableDomainDivision = isEnableDomainDivision;
44+
}
45+
46+
private UserInfo buildUserInfo(String username, String userGroupId) {
47+
return UserInfo.builder().username(username).userGroupId(userGroupId).build();
48+
}
49+
50+
/**
51+
* 获取资源前的切面处理。
52+
*
53+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
54+
*/
55+
@Before("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
56+
public void beforeGet(JoinPoint joinPoint) {
57+
if (!this.isEnableDomainDivision) {
58+
return;
59+
}
60+
String username = this.getUserName();
61+
if (this.allGroupUsers != null && this.allGroupUsers.contains(username)) {
62+
return;
63+
}
64+
UserGroup userGroup = this.getUserGroup(username);
65+
UserInfo userInfo = this.buildUserInfo(username, userGroup.getId());
66+
UserInfoHolder.set(userInfo);
67+
}
68+
69+
/**
70+
* 获取资源后的切面处理。
71+
*
72+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
73+
*/
74+
@After("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
75+
public void afterGet(JoinPoint joinPoint) {
76+
this.clear();
77+
}
78+
79+
/**
80+
* 获取资源异常后的切面处理。
81+
*
82+
* @param joinPoint 表示连接点的 {@link JoinPoint}。
83+
*/
84+
@AfterThrowing("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
85+
public void afterGetThrowing(JoinPoint joinPoint) {
86+
this.clear();
87+
}
88+
}

0 commit comments

Comments
 (0)