package com.xueyi.system.api.holiday.feign.factory;

import com.alibaba.fastjson2.JSONObject;
import com.xueyi.common.core.web.result.R;
import com.xueyi.system.api.holiday.feign.RemoteHolidayService;
import com.xueyi.system.api.sms.domain.vo.SmsReqEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 会议室服务 降级处理
 *
 * @author xueyi
 */
@Slf4j
@Component
public class RemoteHolidayFallbackFactory implements FallbackFactory<RemoteHolidayService> {

    @Override
    public RemoteHolidayService create(Throwable throwable) {
        log.error("短信服务调用失败:{}", throwable.getMessage());
        return new RemoteHolidayService() {
            @Override
            public JSONObject getHolidays() {
                return  R.fail("工作日服务调用失败:" + throwable.getMessage()).toJson();
            }
        };
    }
}