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.GuestAuthorizeDto;
import com.sptg.estate.api.dto.GuestRecordDto;
import com.sptg.estate.api.entity.GuestAuthorize;
import com.sptg.estate.api.entity.GuestRecord;
import com.sptg.estate.api.feigns.GuestAuthorizeFeign;
import com.sptg.estate.api.feigns.GuestRecordFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

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

/**
 * title: GuestAuthorizeFeignFallbackFactory
 * package: com.sptg.estate.api.feigns.fallback
 * description: 访客授权记录 服务接口容错处理
 *
 *
 *
 */
@Component
@Slf4j
public class GuestRecordFeignFallbackFactory implements FallbackFactory<GuestRecordFeign> {
    @Override
    public GuestRecordFeign create(Throwable cause) {
       return new GuestRecordFeign() {
           @Override
           public Page<GuestRecord> showGuestRecordList(GuestRecordDto guestRecordDto) {
               log.error(cause.getMessage(),cause);
               return guestRecordDto.getPage();
           }

           @Override
           public ResultBean<GuestRecord> addGuestRecord(GuestRecord guestRecord) {
               log.error(cause.getMessage(),cause);
               return new ResultBean<>(ResultEnum.ERROR);
           }

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

           @Override
           public ResultBean<Boolean> updateGuestRecord(GuestRecordDto guestRecordDto) {
               log.error(cause.getMessage(),cause);
               return new ResultBean<>(ResultEnum.ERROR);
           }

           @Override
           public ResultBean<Boolean> deleteGuestRecord(GuestRecordDto guestRecordDto) {
               log.error(cause.getMessage(),cause);
               return new ResultBean<>(ResultEnum.ERROR);
           }

           @Override
           public ResultBean<Boolean> updateGuestRecordAuditStatus(GuestRecord guestRecord) {
               log.error(cause.getMessage(),cause);
               return new ResultBean<>(ResultEnum.ERROR);
           }

           @Override
           public ResultBean<GuestRecord> getListByUserId(List<Long> userIds) {
               log.error(cause.getMessage(),cause);
               return new ResultBean<>(ResultEnum.ERROR);
           }

           @Override
           public List<GuestRecord> findByCondition(GuestRecord guestRecord) {
               log.error(cause.getMessage(),cause);
               return null;
           }
       };
    }
}
