新增治理对外接口
This commit is contained in:
@@ -38,6 +38,11 @@
|
|||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>common-microservice</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.njcn.algorithm.api;
|
||||||
|
|
||||||
|
import com.njcn.algorithm.api.fallback.EquipmentFeignClientFallbackFactory;
|
||||||
|
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ALGORITHM_BOOT, path = "/EquipmentDelivery", fallbackFactory = EquipmentFeignClientFallbackFactory.class,contextId = "EquipmentDelivery")
|
||||||
|
public interface EquipmentFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/queryEquipmentByndid")
|
||||||
|
HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.njcn.algorithm.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.algorithm.api.EquipmentFeignClient;
|
||||||
|
import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class EquipmentFeignClientFallbackFactory implements FallbackFactory<EquipmentFeignClient> {
|
||||||
|
@Override
|
||||||
|
public EquipmentFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
// exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new EquipmentFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(String ndid) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","通过ndid查询出厂设备异常",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -101,44 +101,44 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- <plugin>-->
|
<plugin>
|
||||||
<!-- <groupId>com.spotify</groupId>-->
|
<groupId>com.spotify</groupId>
|
||||||
<!-- <artifactId>docker-maven-plugin</artifactId>-->
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
<!-- <version>1.0.0</version>-->
|
<version>1.0.0</version>
|
||||||
<!-- <executions>-->
|
<executions>
|
||||||
<!-- <!–执行mvn package,即执行 mvn clean package docker:build–>-->
|
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||||
<!-- <execution>-->
|
<execution>
|
||||||
<!-- <id>build-image</id>-->
|
<id>build-image</id>
|
||||||
<!-- <phase>${docker.operate}</phase>-->
|
<phase>${docker.operate}</phase>
|
||||||
<!-- <goals>-->
|
<goals>
|
||||||
<!-- <goal>build</goal>-->
|
<goal>build</goal>
|
||||||
<!-- </goals>-->
|
</goals>
|
||||||
<!-- </execution>-->
|
</execution>
|
||||||
<!-- </executions>-->
|
</executions>
|
||||||
<!-- <configuration>-->
|
<configuration>
|
||||||
<!-- <!–<serverId>36dockerHarbor</serverId>–>-->
|
<!--<serverId>36dockerHarbor</serverId>-->
|
||||||
<!-- <registryUrl>http://${docker.repostory}</registryUrl>-->
|
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||||
<!-- <!– 镜像名称 –>-->
|
<!-- 镜像名称 -->
|
||||||
<!-- <imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}</imageName>-->
|
<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}</imageName>
|
||||||
<!-- <!– 指定标签 –>-->
|
<!-- 指定标签 -->
|
||||||
<!-- <imageTags>-->
|
<imageTags>
|
||||||
<!-- <imageTag>latest</imageTag>-->
|
<imageTag>latest</imageTag>
|
||||||
<!-- </imageTags>-->
|
</imageTags>
|
||||||
<!-- <!– 指定远程 Docker API地址 –>-->
|
<!-- 指定远程 Docker API地址 -->
|
||||||
<!-- <dockerHost>${docker.url}</dockerHost>-->
|
<dockerHost>${docker.url}</dockerHost>
|
||||||
<!-- <dockerDirectory>${basedir}/</dockerDirectory>-->
|
<dockerDirectory>${basedir}/</dockerDirectory>
|
||||||
<!-- <!– 复制 jar包到docker容器指定目录–>-->
|
<!-- 复制 jar包到docker容器指定目录-->
|
||||||
<!-- <resources>-->
|
<resources>
|
||||||
<!-- <resource>-->
|
<resource>
|
||||||
<!-- <targetPath>/ROOT</targetPath>-->
|
<targetPath>/ROOT</targetPath>
|
||||||
<!-- <!– 用于指定需要复制的根目录,${project.build.directory}表示target目录 –>-->
|
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
|
||||||
<!-- <directory>${project.build.directory}</directory>-->
|
<directory>${project.build.directory}</directory>
|
||||||
<!-- <!– 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 –>-->
|
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
|
||||||
<!-- <include>${project.build.finalName}.jar</include>-->
|
<include>${project.build.finalName}.jar</include>
|
||||||
<!-- </resource>-->
|
</resource>
|
||||||
<!-- </resources>-->
|
</resources>
|
||||||
<!-- </configuration>-->
|
</configuration>
|
||||||
<!-- </plugin>-->
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class EquipmentDeliveryController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/queryEquipmentByndid")
|
@PostMapping("/queryEquipmentByndid")
|
||||||
@ApiOperation("通过ndid查询出厂设备")
|
@ApiOperation("通过ndid查询出厂设备")
|
||||||
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
|
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
|
||||||
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){
|
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public interface ServerInfo {
|
|||||||
String QUALITY = "quality-boot";
|
String QUALITY = "quality-boot";
|
||||||
String PROCESS = "process-boot";
|
String PROCESS = "process-boot";
|
||||||
String PREPARE_BOOT = "prepare-boot";
|
String PREPARE_BOOT = "prepare-boot";
|
||||||
|
String ALGORITHM_BOOT = "algorithm-boot";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user