package com.mortals.xhx.feign.window;

import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.holiday.HolidayPdu;
import com.mortals.xhx.common.pdu.window.WindowPdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 大厅窗口 Feign接口
 */
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = WindowFeignFallbackFactory.class)
public interface IWindowFeign extends IFeign {

    @PostMapping(value = "/window/interlist")
    Rest<RespData<List<WindowPdu>>> list(@RequestBody WindowPdu windowPdu);





}

@Slf4j
@Component
class WindowFeignFallbackFactory implements FallbackFactory<IWindowFeign> {

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

            @Override
            public Rest<RespData<List<WindowPdu>>> list(WindowPdu windowPdu) {
                return Rest.fail("暂时无法访问窗口列表接口，请稍后再试!");
            }
        };
    }
}
