mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
fix(v0.11): 走查项——事件模块空安全、条件类名、设备筛选与占位接口
- EventConfiguration 标注 @Configuration,Bean 方法改为 cloudwalkEventInitializing - CloudwalkEventManager 对 handler/custom 映射链式 get 做空映射兜底 - EventHandlerMapping / CloudwalkEventInitializing 中 EventType 原型判空 - Rest 层 @ConditionalOnMissingClass 指向正确的本地实现类全名 - RestDeviceServiceImpl:deviceType 与设备类型树数据的 NPE 防护 - PersonRuleServiceImpl:未实现方法返回 CloudwalkResult.fail 替代 null Made-with: Cursor
This commit is contained in:
+2
-1
@@ -175,7 +175,8 @@ public class CloudwalkEventInitializing implements CommandLineRunner {
|
||||
|
||||
private EventType getEventType(Class<? extends BaseEvent> eventClass) {
|
||||
for (EventType eventType : EventType.values()) {
|
||||
if (eventType.getEventClass().getClass().equals(eventClass)) {
|
||||
BaseEvent prototype = eventType.getEventClass();
|
||||
if (prototype != null && prototype.getClass().equals(eventClass)) {
|
||||
return eventType;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-5
@@ -10,7 +10,9 @@ import cn.cloudwalk.event.handler.EventHandlerWorker;
|
||||
import cn.cloudwalk.event.listener.GroupEventListener;
|
||||
import cn.cloudwalk.event.listener.GroupListnerClassMapping;
|
||||
import cn.cloudwalk.event.task.EventHandleTask;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -29,14 +31,24 @@ public class CloudwalkEventManager {
|
||||
public void handle(Class<? extends GroupEventListener> eventListnerClass, BaseEvent baseEvent) {
|
||||
String groupId = this.groupListnerClassMapping.getGroupId(eventListnerClass);
|
||||
if (baseEvent instanceof CustomEvent) {
|
||||
List<CustomEventHandler> customEventHandlers = (List<CustomEventHandler>)this.eventHandlerMapping
|
||||
.getServiceCodeCustomHandlerListMap(groupId, ((CustomEvent)baseEvent).getTopic())
|
||||
.get(baseEvent.getServiceCode());
|
||||
Map<String, List<CustomEventHandler>> customByServiceCode =
|
||||
this.eventHandlerMapping.getServiceCodeCustomHandlerListMap(groupId,
|
||||
((CustomEvent)baseEvent).getTopic());
|
||||
if (customByServiceCode == null) {
|
||||
customByServiceCode = Collections.emptyMap();
|
||||
}
|
||||
List<CustomEventHandler> customEventHandlers =
|
||||
(List<CustomEventHandler>)customByServiceCode.get(baseEvent.getServiceCode());
|
||||
eventHandle(baseEvent, customEventHandlers);
|
||||
return;
|
||||
}
|
||||
List<EventHandler> handlerList = (List<EventHandler>)this.eventHandlerMapping
|
||||
.getServiceCodeHandlerListMap(groupId, baseEvent.getClass()).get(baseEvent.getServiceCode());
|
||||
Map<String, List<EventHandler>> handlerByServiceCode =
|
||||
this.eventHandlerMapping.getServiceCodeHandlerListMap(groupId, baseEvent.getClass());
|
||||
if (handlerByServiceCode == null) {
|
||||
handlerByServiceCode = Collections.emptyMap();
|
||||
}
|
||||
List<EventHandler> handlerList =
|
||||
(List<EventHandler>)handlerByServiceCode.get(baseEvent.getServiceCode());
|
||||
eventHandle(baseEvent, handlerList);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -4,10 +4,12 @@ import cn.cloudwalk.event.CloudwalkEventInitializing;
|
||||
import cn.cloudwalk.event.CloudwalkEventManager;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 事件模块 Spring 配置:注册 {@link cn.cloudwalk.event.CloudwalkEventManager} 与初始化组件。
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({EventProperties.class})
|
||||
public class EventConfiguration {
|
||||
@Bean
|
||||
@@ -16,7 +18,7 @@ public class EventConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CloudwalkEventInitializing CloudwalkEventInitializing(EventProperties eventProperties) {
|
||||
public CloudwalkEventInitializing cloudwalkEventInitializing(EventProperties eventProperties) {
|
||||
return new CloudwalkEventInitializing(eventProperties);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ public class EventHandlerMapping {
|
||||
public Map<String, List<EventHandler>> getServiceCodeHandlerListMap(String groupId,
|
||||
Class<? extends BaseEvent> eventClass) {
|
||||
for (EventType eventType : EventType.values()) {
|
||||
if (eventType.getEventClass().getClass().equals(eventClass)) {
|
||||
BaseEvent prototype = eventType.getEventClass();
|
||||
if (prototype != null && prototype.getClass().equals(eventClass)) {
|
||||
return getServiceCodeHandlerListMap(groupId, eventType);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -298,7 +298,7 @@ public class PersonRuleServiceImpl extends AbstractAcsPassService implements Per
|
||||
|
||||
public CloudwalkResult<Boolean> edit(AcsPersonEditParam param, CloudwalkCallContext context)
|
||||
throws ServiceException {
|
||||
return null;
|
||||
return CloudwalkResult.fail("76260998", "人员规则编辑接口未实现");
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> delete(AcsPersonDeleteParam param, CloudwalkCallContext context)
|
||||
@@ -447,12 +447,12 @@ public class PersonRuleServiceImpl extends AbstractAcsPassService implements Per
|
||||
|
||||
public CloudwalkResult<AcsPersonTimeDetailResult> timeDetail(AcsPersonTimeDetailParam param,
|
||||
CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
return CloudwalkResult.fail("76260998", "人员时段详情接口未实现");
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsPersonResult>> pageByApp(AcsPersonQueryByAppParam param,
|
||||
CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
return CloudwalkResult.fail("76260998", "应用端人员分页接口未实现");
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<ImageStorePersonResult>> personDetail(PersonDetailQueryParam param,
|
||||
|
||||
+19
-7
@@ -13,9 +13,10 @@ import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.rest.cwoscomponent.intelligent.device.config.DeviceCategoryProperties;
|
||||
import cn.cloudwalk.rest.cwoscomponent.intelligent.device.feign.DeviceFeignClient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -40,7 +41,8 @@ public class RestDeviceServiceImpl implements DeviceService {
|
||||
|
||||
public CloudwalkResult<List<DeviceResult>> filterList(Integer deviceType, DeviceQueryParam param,
|
||||
CloudwalkCallContext context) throws ServiceException {
|
||||
if (StringUtils.isEmpty(param.getDeviceTypeCode()) && CollectionUtils.isEmpty(param.getDeviceTypeCodes())) {
|
||||
if (deviceType != null && StringUtils.isEmpty(param.getDeviceTypeCode())
|
||||
&& CollectionUtils.isEmpty(param.getDeviceTypeCodes())) {
|
||||
if (deviceType.intValue() == 1) {
|
||||
List<String> deviceCategoryIds = this.deviceCategoryProperties.getDeviceCategoryArray();
|
||||
if (!CollectionUtils.isEmpty(deviceCategoryIds)) {
|
||||
@@ -58,15 +60,25 @@ public class RestDeviceServiceImpl implements DeviceService {
|
||||
|
||||
public List<String> getDeviceTypeCodes(List<String> deviceCategoryIds) throws ServiceException {
|
||||
CloudwalkResult<List<DeviceTypeResult>> deviceTypeResultList = this.deviceTypeService.getCacheAble();
|
||||
Map<String, DeviceTypeResult> deviceTypeResultMap =
|
||||
(Map<String, DeviceTypeResult>)((List)deviceTypeResultList.getData()).stream()
|
||||
.collect(Collectors.toMap(DeviceTypeResult::getId, d -> d));
|
||||
if (deviceTypeResultList == null || deviceTypeResultList.getData() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DeviceTypeResult> dataList = deviceTypeResultList.getData();
|
||||
Map<String, DeviceTypeResult> deviceTypeResultMap = dataList.stream().filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(DeviceTypeResult::getId, d -> d, (a, b) -> a));
|
||||
List<String> deviceTypeCodes = new ArrayList<>();
|
||||
for (String deviceCategoryId : deviceCategoryIds) {
|
||||
DeviceTypeResult deviceTypeResult = deviceTypeResultMap.get(deviceCategoryId);
|
||||
if (deviceTypeResult == null) {
|
||||
continue;
|
||||
}
|
||||
List<DeviceTypeResult.DeviceTypeDetailResult> children = deviceTypeResult.getChildren();
|
||||
deviceTypeCodes.addAll((Collection<? extends String>)children.stream()
|
||||
.map(DeviceTypeResult.DeviceTypeDetailResult::getDeviceTypeCode).collect(Collectors.toList()));
|
||||
if (CollectionUtils.isEmpty(children)) {
|
||||
continue;
|
||||
}
|
||||
deviceTypeCodes.addAll(children.stream().filter(Objects::nonNull)
|
||||
.map(DeviceTypeResult.DeviceTypeDetailResult::getDeviceTypeCode).filter(Objects::nonNull)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return deviceTypeCodes;
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClas
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.record.service.AcsRecordServiceImpl"})
|
||||
@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.record.service.AcsRecordThreeSendServiceImpl"})
|
||||
public class AcsRecordThreeSendServiceImpl implements AcsRecordThreeSendService {
|
||||
@Autowired
|
||||
private AcsRecordThreeSendFeignClient acsRecordThreeSendFeignClient;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClas
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.resource.service.SysettingAreaServiceImpl"})
|
||||
@ConditionalOnMissingClass({"cn.cloudwalk.service.cwoscomponent.intelligent.sysetting.service.SysettingAreaServiceImpl"})
|
||||
public class RestSysettingAreaServiceImpl implements SysettingAreaService {
|
||||
@Autowired
|
||||
private SysettingAreaFeignClient sysettingAreaFeignClient;
|
||||
|
||||
Reference in New Issue
Block a user