feat: 实现客户端与服务器端Tasker通信机制及文件管理功能
refactor: 重构Tasker基类与服务获取逻辑 fix: 修复文件路径显示问题及任务注册加载机制 docs: 添加客户端与服务器端Tasker通信规则文档 style: 优化代码格式与日志输出 build: 添加tasker_mapper.json配置文件 chore: 清理无用代码与文件
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.task;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -27,36 +28,32 @@ public abstract class Tasker<T> extends Task<T> {
|
||||
@Setter
|
||||
protected java.util.function.Predicate<Message> messageHandler;
|
||||
private EmployeeVo currentUser;
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
@Setter
|
||||
private EmployeeService employeeService;
|
||||
@Setter
|
||||
private SysConfService confService;
|
||||
private HashMap<Class<?>, Object> cachedMap = new HashMap<>();
|
||||
|
||||
public SysConfService getConfService() {
|
||||
if (confService == null) {
|
||||
confService = getBean(SysConfService.class);
|
||||
}
|
||||
return confService;
|
||||
return getBean(SysConfService.class);
|
||||
}
|
||||
|
||||
public CompanyService getCompanyService() {
|
||||
if (companyService == null) {
|
||||
companyService = getBean(CompanyService.class);
|
||||
}
|
||||
return companyService;
|
||||
return getBean(CompanyService.class);
|
||||
}
|
||||
|
||||
public EmployeeService getEmployeeService() {
|
||||
if (employeeService == null) {
|
||||
employeeService = getBean(EmployeeService.class);
|
||||
}
|
||||
return employeeService;
|
||||
return getBean(EmployeeService.class);
|
||||
}
|
||||
|
||||
protected <K> K getBean(Class<K> requiredType) throws BeansException {
|
||||
return SpringApp.getBean(requiredType);
|
||||
return getCachedBean(requiredType);
|
||||
}
|
||||
|
||||
protected <K> K getCachedBean(Class<K> requiredType) {
|
||||
@SuppressWarnings("unchecked")
|
||||
K bean = (K) cachedMap.get(requiredType);
|
||||
if (bean == null) {
|
||||
bean = getBean(requiredType);
|
||||
cachedMap.put(requiredType, bean);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public EmployeeVo getCurrentUser() {
|
||||
@@ -72,7 +69,6 @@ public abstract class Tasker<T> extends Task<T> {
|
||||
try {
|
||||
return execute(holder);
|
||||
} catch (Exception e) {
|
||||
|
||||
holder.error(e.getMessage());
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user