package com.yuchen.saas.parking.api.feign;

import com.yuchen.saas.parking.api.dto.*;
import com.yuchen.saas.parking.api.entity.ParkingPlace;
import com.yuchen.saas.parking.api.entity.ParkingPlacePerson;
import com.yuchen.saas.parking.api.util.SaasParkingFeignFallbackUtils;
import com.yuchen.saas.parking.api.vo.ParkingPlaceHasVO;
import com.yuchen.saas.parking.api.vo.ParkingPlaceMyVO;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author yuanzhelin
 * @Date 2024/11/30 17:06
 * @Description TODO
 */
@Component
public class ParkingPlaceClientFallback implements FallbackFactory<ParkingPlaceClient> {
    @Override
    public ParkingPlaceClient create(Throwable throwable) {
        return new ParkingPlaceClient() {
            @Override
            public R syncPlacePerson(List<ParkingPlacePersonSyncDTO> dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Boolean> syncPlace(List<ParkingPlaceSyncDTO> dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<ParkingPlaceHasVO>> propertyPlace(ParkingPlaceHasQueryDTO dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<ParkingPlacePerson>> ownedPlaces(ParkingPlacePersonQueryDTO dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<ParkingPlace>> selectPlace(ParkingPlaceSelectQueryDTO dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<List<ParkingPlaceMyVO>> myPlacePage(ParkingPlaceMyQueryDTO dto) {
                return SaasParkingFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
