Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

150 changes: 150 additions & 0 deletions app-builder/plugins/aipp-domain-division/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>modelengine.fit.jade</groupId>
<artifactId>app-builder-plugin-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<groupId>modelengine.fit.jade.plugin</groupId>
<artifactId>aipp-domain-division</artifactId>

<dependencies>
<!-- FIT -->
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-api</artifactId>
</dependency>
<dependency>
<groupId>org.fitframework.service</groupId>
<artifactId>fit-http-classic</artifactId>
</dependency>
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-util</artifactId>
</dependency>

<!-- Services -->
<dependency>
<groupId>modelengine.jade.service</groupId>
<artifactId>aipp-domain-division-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>modelengine.fit.jade.service</groupId>
<artifactId>authentication-service</artifactId>
</dependency>
<dependency>
<groupId>modelengine.fit.jade.service</groupId>
<artifactId>common-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<!-- Third-party -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.fitframework.integration</groupId>
<artifactId>fit-mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.fitframework.integration</groupId>
<artifactId>fit-druid</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-test-framework</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.fitframework</groupId>
<artifactId>fit-build-maven-plugin</artifactId>
<version>${fit.version}</version>
<configuration>
<category>user</category>
<level>3</level>
</configuration>
<executions>
<execution>
<id>build-plugin</id>
<goals>
<goal>build-plugin</goal>
</goals>
</execution>
<execution>
<id>package-plugin</id>
<goals>
<goal>package-plugin</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven.antrun.version}</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="${project.build.directory}/${project.build.finalName}.jar"
todir="../../../build/plugins"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

package modelengine.fit.jade.aipp.domain.division.aop;

import modelengine.fit.http.client.HttpClassicClientFactory;
import modelengine.fit.jade.aipp.domain.division.UserGroup;
import modelengine.fit.jade.aipp.domain.division.entity.UserInfo;
import modelengine.fit.jade.aipp.domain.division.entity.UserInfoHolder;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.annotation.Scope;
import modelengine.fitframework.annotation.Value;
import modelengine.fitframework.aop.JoinPoint;
import modelengine.fitframework.aop.annotation.After;
import modelengine.fitframework.aop.annotation.AfterThrowing;
import modelengine.fitframework.aop.annotation.Aspect;
import modelengine.fitframework.aop.annotation.Before;
import modelengine.fitframework.util.StringUtils;

/**
* 表示创建资源的切面
*
* @author 邬涨财
* @since 2025-08-12
*/
@Aspect(scope = Scope.GLOBAL)
@Component
public class CreateSourceAspect extends SourceAspect {
private final String allGroupId;
private final String allGroupAliasId;
private final boolean isEnableDomainDivision;

public CreateSourceAspect(@Value("${domain-division.all-group.id}") final String allGroupId,
@Value("${domain-division.all-group.alias.id}") final String allGroupAliasId,
HttpClassicClientFactory httpClientFactory,
@Value("${domain-division.host}") final String allGroupHost,
@Value("${domain-division.path}") final String allGroupPath,
@Value("${domain-division.isEnable}") boolean isEnableDomainDivision) {
super(httpClientFactory, allGroupHost + allGroupPath);
this.allGroupId = allGroupId;
this.allGroupAliasId = allGroupAliasId;
this.isEnableDomainDivision = isEnableDomainDivision;
}

private UserInfo buildUserInfo(String username, String userGroupId) {
return UserInfo.builder().username(username).userGroupId(userGroupId).build();
}

/**
* 资源创建前的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@Before("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
public void beforeCreate(JoinPoint joinPoint) {
if (!this.isEnableDomainDivision) {
return;
}
String username = this.getUserName();
UserGroup userGroup = this.getUserGroup(username);
String id = userGroup.getId();
if (StringUtils.equals(this.allGroupAliasId, id)) {
id = this.allGroupId;
}
UserInfo userInfo = this.buildUserInfo(username, id);
UserInfoHolder.set(userInfo);
}

/**
* 资源创建后的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@After("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
public void afterCreate(JoinPoint joinPoint) {
this.clear();
}

/**
* 资源创建出现异常后的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@AfterThrowing("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.CreateSource)")
public void afterCreateThrowing(JoinPoint joinPoint) {
this.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

package modelengine.fit.jade.aipp.domain.division.aop;

import modelengine.fit.http.client.HttpClassicClientFactory;
import modelengine.fit.jade.aipp.domain.division.UserGroup;
import modelengine.fit.jade.aipp.domain.division.entity.UserInfo;
import modelengine.fit.jade.aipp.domain.division.entity.UserInfoHolder;
import modelengine.fitframework.annotation.Component;
import modelengine.fitframework.annotation.Scope;
import modelengine.fitframework.annotation.Value;
import modelengine.fitframework.aop.JoinPoint;
import modelengine.fitframework.aop.annotation.After;
import modelengine.fitframework.aop.annotation.AfterThrowing;
import modelengine.fitframework.aop.annotation.Aspect;
import modelengine.fitframework.aop.annotation.Before;

import java.util.List;

/**
* 表示获取资源的切面
*
* @author 邬涨财
* @since 2025-08-12
*/
@Aspect(scope = Scope.GLOBAL)
@Component
public class GetSourceAspect extends SourceAspect {
private final List<String> allGroupUsers;
private final boolean isEnableDomainDivision;

public GetSourceAspect(@Value("${domain-division.all-group.users}") final List<String> allGroupUsers,
HttpClassicClientFactory httpClientFactory,
@Value("${domain-division.host}") final String allGroupHost,
@Value("${domain-division.path}") final String allGroupPath,
@Value("${domain-division.isEnable}") boolean isEnableDomainDivision) {
super(httpClientFactory, allGroupHost + allGroupPath);
this.allGroupUsers = allGroupUsers;
this.isEnableDomainDivision = isEnableDomainDivision;
}

private UserInfo buildUserInfo(String username, String userGroupId) {
return UserInfo.builder().username(username).userGroupId(userGroupId).build();
}

/**
* 获取资源前的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@Before("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
public void beforeGet(JoinPoint joinPoint) {
if (!this.isEnableDomainDivision) {
return;
}
String username = this.getUserName();
if (this.allGroupUsers != null && this.allGroupUsers.contains(username)) {
return;
}
UserGroup userGroup = this.getUserGroup(username);
UserInfo userInfo = this.buildUserInfo(username, userGroup.getId());
UserInfoHolder.set(userInfo);
}

/**
* 获取资源后的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@After("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
public void afterGet(JoinPoint joinPoint) {
this.clear();
}

/**
* 获取资源异常后的切面处理。
*
* @param joinPoint 表示连接点的 {@link JoinPoint}。
*/
@AfterThrowing("@annotation(modelengine.fit.jade.aipp.domain.division.annotation.GetSource)")
public void afterGetThrowing(JoinPoint joinPoint) {
this.clear();
}
}
Loading