移除 yudao-spring-boot-starter-extension

pull/4/head
YunaiV 2022-06-16 09:03:08 +08:00
parent 97bcee429b
commit 64c478a45b
28 changed files with 0 additions and 209 deletions

View File

@ -25,7 +25,6 @@
<module>yudao-spring-boot-starter-excel</module>
<module>yudao-spring-boot-starter-test</module>
<!-- <module>yudao-spring-boot-starter-extension</module>-->
<module>yudao-spring-boot-starter-biz-operatelog</module>
<module>yudao-spring-boot-starter-biz-dict</module>

View File

@ -24,12 +24,4 @@ public interface DictDataFrameworkService {
*/
DictDataRespDTO parseDictDataFromCache(String type, String label);
/**
*
*
* @param type
* @return
*/
List<DictDataRespDTO> listDictDatasFromCache(String type);
}

View File

@ -1,68 +0,0 @@
<?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">
<parent>
<artifactId>yudao-framework</artifactId>
<groupId>cn.iocoder.cloud</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-spring-boot-starter-extension</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>扩展点组件</description>
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>cn.iocoder.cloud</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- 测试包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 测试包 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,86 +0,0 @@
package cn.iocoder.yudao.framework.extension.core.factory;
import cn.iocoder.yudao.framework.extension.core.BusinessScenario;
import cn.iocoder.yudao.framework.extension.core.point.ExtensionPoint;
import cn.iocoder.yudao.framework.extension.core.stereotype.Extension;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import javax.validation.constraints.NotNull;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @description
* @author Qingchen
* @version 1.0.0
* @date 2021-08-28 23:07
* @class cn.iocoder.yudao.framework.extension.core.factory.ExtensionRegisterFactory.java
*/
@Component
@Slf4j
public class ExtensionRegisterFactory implements ExtensionFactory {
/**
* spring ApplicationContext
*/
private ApplicationContext applicationContext;
/**
*
*/
private Map<String, ExtensionDefinition> registerExtensionBeans = new ConcurrentHashMap<>();
@Override
public void register(String basePackage) {
final Map<String, Object> beans = applicationContext.getBeansWithAnnotation(Extension.class);
if(beans == null || beans.isEmpty()) {
return;
}
beans.values().forEach(point -> doRegister((ExtensionPoint) point));
log.info("业务场景相关扩展点注册完成,注册数量: {}", registerExtensionBeans.size());
}
@Override
public <T extends ExtensionPoint> T get(BusinessScenario businessScenario, Class<T> clazz) {
final ExtensionDefinition definition = registerExtensionBeans.get(businessScenario.getUniqueIdentity());
if(definition == null) {
log.error("获取业务场景扩展点实现失败,失败原因:尚未定义该业务场景相关扩展点。{}", businessScenario);
throw new RuntimeException("尚未定义该业务场景相关扩展点 [" + businessScenario + "]");
}
return (T) definition.getExtensionPoint();
}
/**
*
* @param point
*/
private void doRegister(@NotNull ExtensionPoint point) {
Class<?> extensionClazz = point.getClass();
if (AopUtils.isAopProxy(point)) {
extensionClazz = ClassUtils.getUserClass(point);
}
Extension extension = AnnotationUtils.findAnnotation(extensionClazz, Extension.class);
final BusinessScenario businessScenario = BusinessScenario.valueOf(extension.businessId(), extension.useCase(), extension.scenario());
final ExtensionDefinition definition = ExtensionDefinition.valueOf(businessScenario, point);
final ExtensionDefinition exist = registerExtensionBeans.get(businessScenario.getUniqueIdentity());
if(exist != null && !exist.equals(definition)) {
throw new RuntimeException("相同的业务场景重复注册了不同类型的扩展点实现 :【" + definition + "】【" + exist + "】");
}
registerExtensionBeans.put(businessScenario.getUniqueIdentity(), definition);
}
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
}

View File

@ -1,41 +0,0 @@
package cn.iocoder.yudao.framework.extension.core.stereotype;
import cn.iocoder.yudao.framework.extension.core.BusinessScenario;
import org.springframework.stereotype.Component;
import java.lang.annotation.*;
/**
* @description
* @author Qingchen
* @version 1.0.0
* @date 2021-08-28 21:59
* @class cn.iocoder.yudao.framework.extension.core.stereotype.Extension.java
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Component
public @interface Extension {
/**
* <br/>
* tmall
* @return
*/
String businessId() default BusinessScenario.DEFAULT_BUSINESS_ID;
/**
* <br/>
*
* @return
*/
String useCase() default BusinessScenario.DEFAULT_USECASE;
/**
* <br/>
* Instance"订单支付""微信支付"
* @return
*/
String scenario() default BusinessScenario.DEFAULT_SCENARIO;
}

View File

@ -163,11 +163,6 @@ public class DictDataServiceImpl implements DictDataService {
return DictDataConvert.INSTANCE.convert02(labelDictDataCache.get(type, label));
}
@Override
public List<DictDataRespDTO> listDictDatasFromCache(String type) {
return DictDataConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values());
}
@Override
public Long createDictData(DictDataCreateReqVO reqVO) {
// 校验正确性