Commit 20237920 by 向延琳

Merge branch 'v1.6.0' of http://192.168.3.233:8090/eshiled-new/ne-shield-standar…

…d-interfaces-api into v1.6.0
2 parents b5e4ccc7 25f7da8f
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.*;
import cn.com.glsx.stdinterface.factory.StatisticsInStoreFallbackFactory;
import cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO;
import cn.com.glsx.stdinterface.dto.VehicleDto;
import cn.com.glsx.stdinterface.factory.VehicleServiceFallbackFactory;
import com.glsx.plat.core.web.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -9,9 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/vehicle", fallbackFactory = StatisticsInStoreFallbackFactory.class, decode404 = true)
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/vehicle",
fallbackFactory = VehicleServiceFallbackFactory.class, decode404 = true)
public interface VehicleServiceClient {
/**
......@@ -23,4 +23,13 @@ public interface VehicleServiceClient {
@GetMapping(value = "/bysn")
public R<VehicleDto> getVehicleBySn(@RequestParam String sn);
/**
* 验证设备组合接口
*
* @param verifyBO
* @return
*/
@PostMapping(value = "/verifyDevicesCompose")
public R verifyDevicesCompose(@RequestBody DevicesComposeVerifyBO verifyBO);
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class DevicesComposeVerifyBO {
/**
* 工单id
*/
private Long workOrderId;
/**
* 车辆id
*/
@NotNull
private Long vehicleId;
/**
* 设备列表
*/
private List<SimpleDeviceItem> devices;
}
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.VehicleServiceClient;
import cn.com.glsx.stdinterface.fallback.VehicleServiceFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
@Component
public class VehicleServiceFallbackFactory implements FallbackFactory<VehicleServiceClient> {
@Override
public VehicleServiceClient create(Throwable throwable) {
VehicleServiceFallbackImpl fallback = new VehicleServiceFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.VehicleServiceClient;
import cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO;
import cn.com.glsx.stdinterface.dto.VehicleDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class VehicleServiceFallbackImpl implements VehicleServiceClient {
@Setter
private Throwable cause;
@Override
public R<VehicleDto> getVehicleBySn(String sn) {
log.warn("getVehicleBySn 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R verifyDevicesCompose(DevicesComposeVerifyBO verifyBO) {
log.warn("verifyDevicesCompose 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!