This commit is contained in:
parent
e3a92a2878
commit
517bee4006
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.airline.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.airline.api.domain.AirlineTempVO;
|
||||||
|
import com.ruoyi.airline.api.factory.RemoteAirlineFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航线服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteAirlineService", value = ServiceNameConstants.AIRLINE_SERVICE, fallbackFactory = RemoteAirlineFallbackFactory.class)
|
||||||
|
public interface RemoteAirlineService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据ID查询航线信息
|
||||||
|
*
|
||||||
|
* @param id 航线ID
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/airline/temp/{id}")
|
||||||
|
R<AirlineTempVO> getAirlineById(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.airline.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.airline.api.RemoteAirlineService;
|
||||||
|
import com.ruoyi.airline.api.domain.AirlineTempVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航线服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteAirlineFallbackFactory implements FallbackFactory<RemoteAirlineService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteAirlineFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteAirlineService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("航线服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteAirlineService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<AirlineTempVO> getAirlineById(String id, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取航线信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.approval.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.approval.api.domain.ApprovalTempVO;
|
||||||
|
import com.ruoyi.approval.api.factory.RemoteApprovalFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteApprovalService", value = ServiceNameConstants.APPROVAL_SERVICE, fallbackFactory = RemoteApprovalFallbackFactory.class)
|
||||||
|
public interface RemoteApprovalService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据ID查询审批信息
|
||||||
|
*
|
||||||
|
* @param id 审批ID
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/approval/temp/{id}")
|
||||||
|
R<ApprovalTempVO> getApprovalById(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.approval.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.approval.api.RemoteApprovalService;
|
||||||
|
import com.ruoyi.approval.api.domain.ApprovalTempVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteApprovalFallbackFactory implements FallbackFactory<RemoteApprovalService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteApprovalFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteApprovalService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("审批服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteApprovalService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<ApprovalTempVO> getApprovalById(String id, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取审批信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.fms.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.fms.api.domain.FmsTempVO;
|
||||||
|
import com.ruoyi.fms.api.factory.RemoteFmsFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FMS服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteFmsService", value = ServiceNameConstants.FMS_SERVICE, fallbackFactory = RemoteFmsFallbackFactory.class)
|
||||||
|
public interface RemoteFmsService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据ID查询FMS信息
|
||||||
|
*
|
||||||
|
* @param id FMS ID
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/fms/temp/{id}")
|
||||||
|
R<FmsTempVO> getFmsById(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.fms.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.fms.api.RemoteFmsService;
|
||||||
|
import com.ruoyi.fms.api.domain.FmsTempVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FMS服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteFmsFallbackFactory implements FallbackFactory<RemoteFmsService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteFmsFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteFmsService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("FMS服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteFmsService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<FmsTempVO> getFmsById(String id, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取FMS信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.media.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.media.api.domain.MediaTempVO;
|
||||||
|
import com.ruoyi.media.api.factory.RemoteMediaFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 媒体服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteMediaService", value = ServiceNameConstants.MEDIA_SERVICE, fallbackFactory = RemoteMediaFallbackFactory.class)
|
||||||
|
public interface RemoteMediaService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据ID查询媒体信息
|
||||||
|
*
|
||||||
|
* @param id 媒体ID
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/media/temp/{id}")
|
||||||
|
R<MediaTempVO> getMediaById(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.media.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.media.api.RemoteMediaService;
|
||||||
|
import com.ruoyi.media.api.domain.MediaTempVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 媒体服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteMediaFallbackFactory implements FallbackFactory<RemoteMediaService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteMediaFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteMediaService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("媒体服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteMediaService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<MediaTempVO> getMediaById(String id, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取媒体信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ruoyi.task.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.task.api.domain.TaskTempVO;
|
||||||
|
import com.ruoyi.task.api.factory.RemoteTaskFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteTaskService", value = ServiceNameConstants.TASK_SERVICE, fallbackFactory = RemoteTaskFallbackFactory.class)
|
||||||
|
public interface RemoteTaskService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 根据ID查询任务信息
|
||||||
|
*
|
||||||
|
* @param id 任务ID
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/task/temp/{id}")
|
||||||
|
R<TaskTempVO> getTaskById(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.task.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.task.api.RemoteTaskService;
|
||||||
|
import com.ruoyi.task.api.domain.TaskTempVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteTaskFallbackFactory implements FallbackFactory<RemoteTaskService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteTaskFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteTaskService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("任务服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteTaskService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<TaskTempVO> getTaskById(String id, String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取任务信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,4 +26,29 @@ public class ServiceNameConstants
|
||||||
* 设备服务的serviceid
|
* 设备服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String DEVICE_SERVICE = "tuoheng-device";
|
public static final String DEVICE_SERVICE = "tuoheng-device";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航线服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String AIRLINE_SERVICE = "tuoheng-airline";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String APPROVAL_SERVICE = "tuoheng-approval";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FMS服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String FMS_SERVICE = "tuoheng-fms";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 媒体服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String MEDIA_SERVICE = "tuoheng-media";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String TASK_SERVICE = "tuoheng-task";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue