package com.crunii.micro.feign.client.fallbackfactory;

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.feign.client.FileManagerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author wangchen create 2023/8/8 15:44
 */
@Component
public class FileManagerFallbackFactory implements FallbackFactory<FileManagerService> {

    private static final Logger logger = LoggerFactory.getLogger(FileManagerFallbackFactory.class);

    @Override
    public FileManagerService create(Throwable cause) {
        logger.error("fallback; exception was: {}", cause.toString());
        logger.error("fallback; reason was: {}", cause.getMessage());
        return labelId -> {
            Result result = new Result();
            result.setSuccess(false);
            result.setMsg("delPicByLabelId接口调用失败");
            return result;
        };
    }
}
