package com.sptg.permissions.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.permissions.api.entity.SmsRecords;
import com.sptg.permissions.api.feigns.SmsFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * title: SmsFeignFallbackFactory
 * package: com.sptg.permissions.api.feigns.fallback
 * description: 单元 服务容错处理类
 *
 *
 *
 */
@Component
@Slf4j
public class SmsFeignFallbackFactory implements FallbackFactory<SmsFeign> {

    @Override
    public SmsFeign create(Throwable cause) {
        return new SmsFeign() {

            @Override
            public ResultBean<Page<SmsRecords>> pagingByCondition(SmsRecords smsRecords) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> insertSms(SmsRecords smsRecords) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
