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

import com.yuchen.saas.park.api.entity.park.PmgBatParkPeople;
import com.yuchen.saas.park.api.entity.park.PmgBatPeopleType;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/11/15 15:19
 * @Description: 人员信息fallback
 * @Version: 1.0
 */
@Component
public class ParkPeopleFeignServiceFallback implements FallbackFactory<ParkPeopleFeignService> {

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

            @Override
            public PmgBatParkPeople getByPhone(String phone) {
                return new PmgBatParkPeople();
            }

            @Override
            public PmgBatParkPeople getById(Long id) {
                return new PmgBatParkPeople();
            }

            @Override
            public R syncPeopleInfo() {
                return R.success();
            }

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

        };
    }
}