parent
f6322db398
commit
1c66e38246
@ -0,0 +1,31 @@
|
||||
package com.xjs.business.api;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.api.domain.Area;
|
||||
import com.xjs.business.api.factory.RemoteAreaFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调用openapi服务AreaController feign
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-03-23
|
||||
*/
|
||||
@FeignClient(contextId = "remoteAreaFeign",
|
||||
value = ServiceNameConstants.BUSINESS_OPENAPI_SERVICE,
|
||||
fallbackFactory = RemoteAreaFactory.class)
|
||||
public interface RemoteAreaFeign {
|
||||
|
||||
@GetMapping("/area/getProvinceAreaForRPC")
|
||||
R<List<Area>> getProvinceAreaForRPC();
|
||||
|
||||
|
||||
@GetMapping("/area/getAreaByParentIdForRPC/{pid}")
|
||||
R<List<Area>> getAreaByParentIdForRPC(@PathVariable("pid") Long pid);
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.xjs.business.api.factory;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.api.RemoteAreaFeign;
|
||||
import com.xjs.business.api.domain.Area;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* RemoteAreaFeign降级
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-03-23
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RemoteAreaFactory implements FallbackFactory<RemoteAreaFeign> {
|
||||
@Override
|
||||
public RemoteAreaFeign create(Throwable cause) {
|
||||
return new RemoteAreaFeign() {
|
||||
@Override
|
||||
public R<List<Area>> getProvinceAreaForRPC() {
|
||||
log.error("API模块获取区域信息降级" + cause.getMessage());
|
||||
return R.fail("API模块获取区域信息降级");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<Area>> getAreaByParentIdForRPC(Long pid) {
|
||||
log.error("API模块根据id获取区域信息降级" + cause.getMessage());
|
||||
return R.fail("API模块根据id获取区域信息降级");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in new issue