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

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.dto.message.SendMessageTaskReqDTO;
import com.crunii.micro.feign.client.MessageService;
import com.crunii.micro.feign.client.SmsService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


/**
 * @ClassName MessageService
 * @Description TODO
 * @Author Jiang
 * @Date 2023/10/31
 * @Version 1.0
 */


@Component
public class MessageFallbackFactory implements FallbackFactory<MessageService> {

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

    @Override
    public MessageService create(Throwable cause) {
        logger.error("fallback; exception was: {}", cause.toString());
        logger.error("fallback; reason was: {}", cause.getMessage());
        return new MessageService() {
            @Override
            public Result saveMessageTask(SendMessageTaskReqDTO taskReqDTO) {
                Result<String> result = new Result();
                result.setSuccess(false);
                result.setMsg("saveMessageTask接口调用失败");
                return result;
            }
        };
    }

}
