package com.sptg.estate.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.estate.api.dto.ParkingLotDto;
import com.sptg.estate.api.entity.ParkingLot;
import com.sptg.estate.api.feigns.ParkingLotFeign;
import com.sptg.estate.api.feigns.ParkingLotFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ParkingLotFeignFallbackFactory implements FallbackFactory<ParkingLotFeign> {
    @Override
    public ParkingLotFeign create(Throwable cause) {
        return new ParkingLotFeign() {
            @Override
            public ResultBean<Page<ParkingLot>> page(ParkingLotDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> add(ParkingLotDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> edit(ParkingLotDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> delete(ParkingLotDto dto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ParkingLot getById(Long id) {
                log.error(cause.getMessage(),cause);
                return null;
            }
        };
    }
}
