完善模板解析功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsGroupClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csGroup", fallbackFactory = CsGroupClientFallbackFactory.class,contextId = "csGroup")
|
||||
|
||||
public interface CsGroupFeignClient {
|
||||
|
||||
@PostMapping("/getGroup")
|
||||
HttpResult<List<CsGroupVO>> getGroupData(@RequestParam("dataSet") String dataSet);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.csdevice.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.api.CsGroupFeignClient;
|
||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsGroupClientFallbackFactory implements FallbackFactory<CsGroupFeignClient> {
|
||||
@Override
|
||||
public CsGroupFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsGroupFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<CsGroupVO>> getGroupData(String dataSet) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询分组",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,9 @@ public enum AlgorithmResponseEnum {
|
||||
REPEAT_SHARE ("A00511","设备已分享完成,请勿再次分享"),
|
||||
DEVICE_LOSE("A00512","设备id缺失"),
|
||||
CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除"),
|
||||
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除");
|
||||
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除"),
|
||||
|
||||
DATA_ARRAY_MISSING("A00515","详细数据为空")
|
||||
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user