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

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

import java.util.List;


/**
 * @author LG
 */
@Component
public class LabelServiceFallbackFactory implements FallbackFactory<LabelService> {
    private static final Logger logger = LoggerFactory.getLogger(LabelServiceFallbackFactory.class);


    @Override
    public LabelService create(Throwable cause) {
        logger.error("fallback; exception was: {}", cause.toString());
        logger.error("fallback; reason was: {}", cause.getMessage());

        return new LabelService() {
            @Override
            public Result<Object> labelUseCount(List<UseCountDto> useCountList) {
                Result result = new Result();
                result.setSuccess(false);
                result.setMsg("labelUseCount接口调用失败");
                return result;
            }
        };
    }
}
