删除Strategy逻辑

This commit is contained in:
jsowell
2026-06-10 16:39:03 +08:00
parent 0521ba95dd
commit 6686e2747f

View File

@@ -1,56 +0,0 @@
package com.jsowell.netty.factory;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.util.StringUtils;
import com.jsowell.netty.strategy.ykc.AbstractYkcStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* 工厂设计模式
* 云快充操作
*/
@Component
public class YKCOperateFactoryV2 {
@Autowired
private Map<String, AbstractYkcStrategy> strategyMap;
private static Map<String, String> operationMap = new HashMap<>();
// static {
// //初始化实现类
// operationMap.put("0x01", "loginRequestStrategy");
// operationMap.put("0x05", "billingTemplateValidateRequestStrategy");
// // more operators
// }
/**
* 注册
* @param str
* @param strategyName
*/
public static void register(String str, String strategyName) {
if (StringUtils.isBlank(str) || StringUtils.isBlank(strategyName)) {
return;
}
// 获取首字母(类名首字母大写), 并将首字母变为小写
strategyName = strategyName.substring(0, 1).toLowerCase() + strategyName.substring(1);
operationMap.put(str, strategyName);
}
/**
* 获取
*/
public AbstractYkcStrategy getInvokeStrategy(String frameType) {
String s = operationMap.get(frameType);
return strategyMap.get(s);
}
public static String getOperationMap() {
return JSON.toJSONString(operationMap);
}
}