mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-16 05:10:04 +08:00
删除Strategy逻辑
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user