程序信息对外接口

This commit is contained in:
xy
2024-09-19 14:25:17 +08:00
parent 46a9922313
commit f86f18817d
8 changed files with 102 additions and 10 deletions

View File

@@ -0,0 +1,27 @@
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.CsSoftInfoClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsSoftInfoPO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csSoftInfo", fallbackFactory = CsSoftInfoClientFallbackFactory.class,contextId = "csSoftInfo")
public interface CsSoftInfoFeignClient {
@PostMapping("/findSoftInfo")
HttpResult<CsSoftInfoPO> findSoftInfo(@RequestParam("id") String id);
@PostMapping("/saveSoftInfo")
HttpResult<String> saveSoftInfo(@RequestBody CsSoftInfoPO po);
@PostMapping("/removeSoftInfo")
HttpResult<String> removeSoftInfo(@RequestParam("id") String id);
}

View File

@@ -0,0 +1,46 @@
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.CsSoftInfoFeignClient;
import com.njcn.csdevice.pojo.po.CsSoftInfoPO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class CsSoftInfoClientFallbackFactory implements FallbackFactory<CsSoftInfoFeignClient> {
@Override
public CsSoftInfoFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsSoftInfoFeignClient() {
@Override
public HttpResult<CsSoftInfoPO> findSoftInfo(String id) {
log.error("{}异常,降级处理,异常为:{}","获取装置软件信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> saveSoftInfo(CsSoftInfoPO po) {
log.error("{}异常,降级处理,异常为:{}","保存软件程序",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> removeSoftInfo(String id) {
log.error("{}异常,降级处理,异常为:{}","删除软件程序",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -46,7 +46,7 @@ public class DeviceManagerVO {
private String appVersion;
@ApiModelProperty(value = "应用程序发布日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private LocalDateTime appDate;
@ApiModelProperty(value = "应用程序校验码")