package com.sptg.third.api.feigns.grid.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.estate.api.dto.BaseUser;
import com.sptg.estate.api.entity.*;
import com.sptg.permissions.api.entity.Organization;
import com.sptg.third.api.feigns.grid.GridEstateFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zwx
 * @create 2020/11/28 20:19
 */
@Slf4j
@Component
public class GridEstateFeignFallbackFactory implements FallbackFactory<GridEstateFeign> {
    @Override
    public GridEstateFeign create(Throwable cause) {
        return new GridEstateFeign() {

            @Override
            public ResultBean<String> gridAgencyPush(Agency agency) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridResidentialPush(Residential residential) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridBuildingPush(Building building) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridFloorPush(Floor floor) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridUnitPush(Unit unit) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridRoomPush(Room room) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridUserPush(ApplyUser applyUser) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> gridEstateRepairPush(EstateRepair estateRepair) {
                log.error(cause.getMessage(), cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
