package com.yuchen.saas.park.api.feign.service;

import com.yuchen.saas.park.api.entity.park.PmgBatParkInfo;
import com.yuchen.saas.park.api.entity.pldoor.PlVisitorPowerSet;
import com.yuchen.saas.park.api.request.PlVisitorParkingSpotRequest;
import com.yuchen.saas.park.api.response.ParkInfoResponse;
import com.yuchen.saas.park.api.vo.park.ApplyManageParkDetailVO;
import com.yuchen.saas.park.api.vo.pldoor.PlIntervieweeVO;
import com.yuchen.saas.park.api.vo.pldoor.PlVisitorSpotVO;
import org.nest.springwrap.core.tool.api.R;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/15 16:19
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class ParkFeignServiceFallback implements FallbackFactory<ParkFeignService> {

    @Override
    public ParkFeignService create(Throwable cause) {

        return new ParkFeignService() {
            @Override
            public R getParkAll() {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R getRoleParkAll() {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PmgBatParkInfo> getParkInfo(Long parkId) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<List<ParkInfoResponse>> getParkListByScopeValue(String tenantId, String scopeValue) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<List<ParkInfoResponse>> getParkList(Long tenantId, Long parkId,String parkName) {
                if (cause != null) {
                    String message = cause.getMessage();
                    return R.error(message);
                }
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<List<PmgBatParkInfo>> getParkAll2() {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<List<PmgBatParkInfo>> getParkInfoListById(Long parkId) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<String> getParkNamesByIds(String parkIds) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<Map<Long, String>> getParkMap(List<Long> parkIds) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<ApplyManageParkDetailVO> bindingDetail(Long parkId) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PmgBatParkInfo> receiveIotEvent(String jsonObjectContent) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PmgBatParkInfo> getSpaceTree(Long parkId) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PlVisitorPowerSet> getPowerSetByProjectId(Long parkId) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<List<PlVisitorSpotVO>> getParkingSpotByParam(PlVisitorParkingSpotRequest request) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<PlIntervieweeVO> getVisitorByParkIdCarNo(Long parkId, String carNo) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<Map<Long, String>> getParkNameMap(List<Long> projectIdList) {
                return R.error("调用接口错误，熔断机制！");
            }

            @Override
            public R<Map<Long, PmgBatParkInfo>> getParkInfoMap(List<Long> projectIdList) {
                return R.error("调用接口错误，熔断机制！");
            }
        };
    }
}