This commit is contained in:
huangzj
2023-09-20 15:33:40 +08:00
parent becaa461ea
commit e9795c5acd
30 changed files with 485 additions and 234 deletions

View File

@@ -0,0 +1,23 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/eventUser", fallbackFactory = EventUserFeignClientFallbackFactory.class,contextId = "eventUser")
public interface EventUserFeignClient {
@PostMapping("/queryEventList")
HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ;
}

View File

@@ -0,0 +1,42 @@
package com.njcn.csharmonic.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.pojo.po.AppProjectPO;
import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class EventUserFeignClientFallbackFactory implements FallbackFactory<EventUserFeignClient> {
@Override
public EventUserFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EventUserFeignClient() {
@PostMapping("/queryEventList")
@Override
public HttpResult<List<EventDetailVO>> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -19,8 +19,8 @@ public class CommonStatisticalQueryParam {
private List<String> lineList;
@ApiModelProperty(value = "设备id")
private String DevId;
@ApiModelProperty(value = "指标id")
@NotBlank(message="指标id不能为空")
@ApiModelProperty(value = "指标id")
@NotBlank(message="指标id不能为空")
private String statisticalId;
@ApiModelProperty(value = "取值类型MaxMincp95avg")
private String valueType;