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.UserFeedbackDto;
import com.sptg.estate.api.entity.UserFeedback;
import com.sptg.estate.api.feigns.UserFeedbackFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class UserFeedbackFeignFallbackFactory implements FallbackFactory<UserFeedbackFeign> {
    @Override
    public UserFeedbackFeign create(Throwable cause) {
        return new UserFeedbackFeign() {
            @Override
            public ResultBean<Page<UserFeedback>> pagingQuery(UserFeedbackDto userFeedbackDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

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

            @Override
            public ResultBean<Boolean> handle(UserFeedbackDto userFeedbackDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<UserFeedback> getOne(UserFeedbackDto userFeedbackDto) {
                log.error(cause.getMessage(),cause);
                return null;
            }

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