完成责任树模式设计测试
parent
f0a69766d4
commit
1e668ce238
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
<artifactId>cloud-data-processing</artifactId>
|
<artifactId>cloud-data-processing</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-data-processing 数据处理模块
|
||||||
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
|
@ -23,8 +23,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
public class MyDataApplication {
|
public class MyDataApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(MyDataApplication.class, args);
|
SpringApplication.run(MyDataApplication.class, args);
|
||||||
System.out.println(KafkaConstants.KafkaGrop);
|
|
||||||
System.out.println(KafkaConstants.KafkaTopic);
|
|
||||||
System.out.println("MyData 模块启动成功!");
|
System.out.println("MyData 模块启动成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@ package com.muyu.data.processing.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.kafka.constants.KafkaConstants;
|
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.root.RootStrategy;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.kafka.core.KafkaTemplate;
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
import org.springframework.messaging.MessageHeaders;
|
import org.springframework.messaging.MessageHeaders;
|
||||||
|
@ -34,8 +37,14 @@ public class TestController {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("同步消息发送失败: " + msg);
|
System.out.println("同步消息发送失败: " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RootStrategy rootStrategy;
|
||||||
|
|
||||||
|
@PostMapping("/testStrategy")
|
||||||
|
public TestResp testStrategy(@RequestBody TestReq testReq) {
|
||||||
|
return rootStrategy.applyStrategy(testReq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.data.processing.domain;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import com.muyu.data.processing.strategy.branch.OneBranchStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.branch.TwoBranchStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.FourLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.OneLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.ThreeLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.TwoLeavesStrategy;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略选择枚举
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: StrategyEums
|
||||||
|
* @Description: 策略选择枚举
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:59
|
||||||
|
* @FilePath: com.muyu.data.processing.domain
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum StrategyEums {
|
||||||
|
TEST1("加减法", new OneBranchStrategy()),
|
||||||
|
TEST2("乘除法", new TwoBranchStrategy()),
|
||||||
|
TEST1_1("加法", new OneLeavesStrategy()),
|
||||||
|
TEST1_2("减法", new TwoLeavesStrategy()),
|
||||||
|
TEST2_1("乘法", new ThreeLeavesStrategy()),
|
||||||
|
TEST2_2("除法", new FourLeavesStrategy());
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final StrategyHandler<TestReq, TestResp> info;
|
||||||
|
|
||||||
|
StrategyEums(String code, StrategyHandler<TestReq, TestResp> info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是枚举的值
|
||||||
|
*
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn, 否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(StrategyEums::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StrategyHandler<TestReq, TestResp> getStrategy(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(c -> c.getCode().equals(code))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("参数错误"))
|
||||||
|
.getInfo();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.muyu.data.processing.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试入参
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: TestReq
|
||||||
|
* @Description: 测试入参
|
||||||
|
* @CreatedDate: 2024/9/28 上午10:40
|
||||||
|
* @FilePath: com.muyu.data.processing.domain.req
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TestReq {
|
||||||
|
private Integer one;
|
||||||
|
private Integer two;
|
||||||
|
|
||||||
|
private String type1;
|
||||||
|
private String type2;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.data.processing.domain.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试出参
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: TestResp
|
||||||
|
* @Description: 测试出参
|
||||||
|
* @CreatedDate: 2024/9/28 上午10:40
|
||||||
|
* @FilePath: com.muyu.data.processing.domain.req.resp
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TestResp {
|
||||||
|
private String resp;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.data.processing.strategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略控制者接口
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: StrategyHandler
|
||||||
|
* @Description: 策略控制者接口
|
||||||
|
* @CreatedDate: 2024/9/28 上午9:35
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy
|
||||||
|
*/
|
||||||
|
public interface StrategyHandler<T,R> {
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
StrategyHandler DEFAULT = t -> null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行方法
|
||||||
|
* @param t 入参
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
R apply(T t);
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.muyu.data.processing.strategy;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
/**
|
||||||
|
* 抽象策略路由
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: abstractStrategyRouter
|
||||||
|
* @Description: 抽象策略路由
|
||||||
|
* @CreatedDate: 2024/9/28 上午9:26
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public abstract class abstractStrategyRouter<T,R> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略映射器, 指定入参与出参以决定策略处理者
|
||||||
|
* @param <T> 策略入参
|
||||||
|
* @param <R> 策略出参
|
||||||
|
*/
|
||||||
|
public interface StrategyMapper<T,R>{
|
||||||
|
// 通过入参获取对应策略处理方法,使用Map实现
|
||||||
|
StrategyHandler<T,R> getHandler(T param);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抽象注册方法
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract StrategyMapper<T,R> registerStrategy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认策略处理者
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private StrategyHandler<T,R> defaultStrategyHandler = StrategyHandler.DEFAULT;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择策略处理者
|
||||||
|
* @param param 入参
|
||||||
|
* @return 策略处理结果
|
||||||
|
*/
|
||||||
|
public R applyStrategy(T param) {
|
||||||
|
final StrategyHandler<T,R> strategyHandler = registerStrategy().getHandler(param);
|
||||||
|
if (strategyHandler != null) {
|
||||||
|
return strategyHandler.apply(param);
|
||||||
|
}
|
||||||
|
// 使用默认策略处理者
|
||||||
|
return defaultStrategyHandler.apply(param);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.data.processing.strategy.branch;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.StrategyEums;
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import com.muyu.data.processing.strategy.abstractStrategyRouter;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.FourLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.OneLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.ThreeLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.TwoLeavesStrategy;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1号分支策略方法实现
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: OneBranchStrategy
|
||||||
|
* @Description: 1号叶子策略方法实现
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:50
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.impl
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class OneBranchStrategy extends abstractStrategyRouter<TestReq, TestResp> implements StrategyHandler<TestReq,TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("1号分支策略方法实现,参数1:{},参数2:{},执行方法:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2());
|
||||||
|
return applyStrategy(testReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StrategyMapper<TestReq, TestResp> registerStrategy() {
|
||||||
|
return param -> StrategyEums.getStrategy(param.getType2());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.data.processing.strategy.branch;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.StrategyEums;
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import com.muyu.data.processing.strategy.abstractStrategyRouter;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.FourLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.OneLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.ThreeLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.TwoLeavesStrategy;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2号分支策略方法实现
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: TwoBranchStrategy
|
||||||
|
* @Description: 1号叶子策略方法实现
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:50
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.impl
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TwoBranchStrategy extends abstractStrategyRouter<TestReq, TestResp> implements StrategyHandler<TestReq,TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("2号分支策略方法实现,参数1:{},参数2:{},执行方法:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2());
|
||||||
|
return applyStrategy(testReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StrategyMapper<TestReq, TestResp> registerStrategy() {
|
||||||
|
return param -> StrategyEums.getStrategy(param.getType2());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.data.processing.strategy.leaves;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 4号处理者
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: FourLeavesStrategy
|
||||||
|
* @Description: 4号处理者
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:54
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.leaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class FourLeavesStrategy implements StrategyHandler<TestReq, TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("4号处理者实现,参数1:{},参数2:{},执行方法:{},结果:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2(), (testReq.getOne()*1.0/testReq.getTwo()));
|
||||||
|
return new TestResp("执行4号处理者-除法");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.data.processing.strategy.leaves;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import com.muyu.data.processing.strategy.abstractStrategyRouter;
|
||||||
|
import com.muyu.data.processing.strategy.branch.OneBranchStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.branch.TwoBranchStrategy;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1号处理者
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: OneLeavesStrategy
|
||||||
|
* @Description: 1号处理者
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:54
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.leaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class OneLeavesStrategy implements StrategyHandler<TestReq, TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("1号处理者实现,参数1:{},参数2:{},执行方法:{},结果:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2(), (testReq.getOne()+testReq.getTwo()));
|
||||||
|
return new TestResp("执行1号处理者-加法");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.data.processing.strategy.leaves;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 3号处理者
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: ThreeLeavesStrategy
|
||||||
|
* @Description: 3号处理者
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:54
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.leaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ThreeLeavesStrategy implements StrategyHandler<TestReq, TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("3号处理者实现,参数1:{},参数2:{},执行方法:{},结果:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2(), (testReq.getOne()*testReq.getTwo()));
|
||||||
|
return new TestResp("执行3号处理者-乘法");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.data.processing.strategy.leaves;
|
||||||
|
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2号处理者
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: TwoLeavesStrategy
|
||||||
|
* @Description: 2号处理者
|
||||||
|
* @CreatedDate: 2024/9/28 上午11:54
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.leaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class TwoLeavesStrategy implements StrategyHandler<TestReq, TestResp> {
|
||||||
|
@Override
|
||||||
|
public TestResp apply(TestReq testReq) {
|
||||||
|
log.info("2号处理者实现,参数1:{},参数2:{},执行方法:{},结果:{}", testReq.getOne(), testReq.getTwo(), testReq.getType2(), (testReq.getOne()-testReq.getTwo()));
|
||||||
|
return new TestResp("执行2号处理者-减法");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.data.processing.strategy.root;
|
||||||
|
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.data.processing.domain.StrategyEums;
|
||||||
|
import com.muyu.data.processing.domain.req.TestReq;
|
||||||
|
import com.muyu.data.processing.domain.resp.TestResp;
|
||||||
|
import com.muyu.data.processing.strategy.StrategyHandler;
|
||||||
|
import com.muyu.data.processing.strategy.abstractStrategyRouter;
|
||||||
|
import com.muyu.data.processing.strategy.branch.OneBranchStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.branch.TwoBranchStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.FourLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.OneLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.ThreeLeavesStrategy;
|
||||||
|
import com.muyu.data.processing.strategy.leaves.TwoLeavesStrategy;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 策略路由实现
|
||||||
|
*
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: RootStrategy
|
||||||
|
* @Description: 策略路由实现
|
||||||
|
* @CreatedDate: 2024/9/28 上午10:39
|
||||||
|
* @FilePath: com.muyu.data.processing.strategy.impl
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RootStrategy extends abstractStrategyRouter<TestReq, TestResp> {
|
||||||
|
@Override
|
||||||
|
protected StrategyMapper<TestReq , TestResp> registerStrategy() {
|
||||||
|
return param -> StrategyEums.getStrategy(param.getType1());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,3 +61,4 @@ spring:
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.system.mapper: DEBUG
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue