package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.TRoleSite; import com.ruoyi.other.api.feignClient.RoleSiteClient; import com.ruoyi.other.api.feignClient.UserSiteClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; import java.util.List; /** * 商品服务降级处理 * * @author ruoyi */ @Component public class RoleSiteFallbackFactory implements FallbackFactory { private static final Logger log = LoggerFactory.getLogger(RoleSiteFallbackFactory.class); @Override public RoleSiteClient create(Throwable throwable) { log.error("调用失败:{}", throwable.getMessage()); return new RoleSiteClient() { @Override public R> getSiteIds(Long roleId) { return R.fail("获取角色站点失败:" + throwable.getMessage()); } @Override public R addRoleSite(List roleSites) { return R.fail("添加角色站点失败:" + throwable.getMessage()); } @Override public R delRoleSite(Long roleId) { return R.fail("删除角色站点失败:" + throwable.getMessage()); } }; } }