mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
update 代码重构
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -19,24 +21,26 @@ public class YKCOperateFactoryV2 {
|
||||
|
||||
private static Map<String, String> operationMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
//初始化实现类
|
||||
operationMap.put("0x01", "loginRequestStrategy");
|
||||
operationMap.put("0x05", "billingTemplateValidateRequestStrategy");
|
||||
// more operators
|
||||
}
|
||||
// static {
|
||||
// //初始化实现类
|
||||
// operationMap.put("0x01", "loginRequestStrategy");
|
||||
// operationMap.put("0x05", "billingTemplateValidateRequestStrategy");
|
||||
// // more operators
|
||||
// }
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param str
|
||||
* @param handler
|
||||
* @param strategyName
|
||||
*/
|
||||
// public void register(String str, AbstractYkcHandlerV2 handler) {
|
||||
// if (StringUtils.isBlank(str) || Objects.isNull(handler)) {
|
||||
// return;
|
||||
// }
|
||||
// strategyMap.put(str, handler);
|
||||
// }
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
@@ -45,4 +49,8 @@ public class YKCOperateFactoryV2 {
|
||||
String s = operationMap.get(frameType);
|
||||
return strategyMap.get(s);
|
||||
}
|
||||
|
||||
public static String getOperationMap() {
|
||||
return JSON.toJSONString(operationMap);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user