This commit is contained in:
王奎兴
2026-08-26 14:08:24 +08:00
parent f2f3fb9c19
commit 02a0b7aab6
7 changed files with 186 additions and 1 deletions
@@ -0,0 +1,23 @@
package com.mhd.system.api;
import com.mhd.common.core.constant.ServiceNameConstants;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.dto.YmsSysUserDTO;
import com.mhd.system.api.domain.YmsLoginUser;
import com.mhd.system.api.factory.RemoteBmsFeignFallbackFactory;
import com.mhd.system.api.factory.RemoteXxlJobFeignFallbackFactory;
import com.mhd.system.api.feign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://127.0.0.1:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface XxlJobServiceFeign {
@GetMapping("/user/openFeignTest")
public R<Map<String, Object>> openFeignTest(@RequestParam("param") String string);
}
@@ -0,0 +1,44 @@
package com.mhd.system.api.factory;
import com.mhd.common.core.domain.dto.BusinessDataPushDTO;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.po.OrganizationPo;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.system.api.BmsServiceFeign;
import com.mhd.system.api.ProductServiceFeign;
import com.mhd.system.api.XxlJobServiceFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Description
* @Author zg
* @Version 1.0
* @Date 2023/11/3 14:37
*/
@Component
public class RemoteXxlJobFeignFallbackFactory implements FallbackFactory<XxlJobServiceFeign> {
private static final Logger log = LoggerFactory.getLogger(RemoteXxlJobFeignFallbackFactory.class);
@Override
public XxlJobServiceFeign create(Throwable throwable) {
log.error("系统服务调用失败:{}", throwable.getMessage());
return new XxlJobServiceFeign() {
@Override
public R<Map<String, Object>> openFeignTest(String string) {
return null;
}
};
}
}