package com.sptg.ad.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdOfflinePushRecordDto;
import com.sptg.ad.api.entity.AdOfflinePushRecord;
import com.sptg.ad.api.feigns.AdOfflinePushRecordFeign;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * title: AdOfflinePushRecordFeignFallbackFactory
 * package: com.sptg.ad.api.feigns.fallback
 * description: 线下广告发布记录接口容错处理
 *
 *
 *
 */
@Slf4j
@Component
public class AdOfflinePushRecordFeignFallbackFactory implements FallbackFactory<AdOfflinePushRecordFeign> {
    @Override
    public AdOfflinePushRecordFeign create(Throwable cause) {
        return new AdOfflinePushRecordFeign() {
            @Override
            public ResultBean<Page<AdOfflinePushRecord>> showAdOfflinePushRecordList(AdOfflinePushRecordDto adOfflinePushRecordDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> addAdOfflinePushRecord(AdOfflinePushRecord adOfflinePushRecord) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Boolean> cancelAdOfflinePushRecord(Long id) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public AdOfflinePushRecord findAdOfflinePushRecordById(Long id) {
                return null;
            }
            @Override
            public ResultBean<Boolean> updateAdOfflinePushRecord(AdOfflinePushRecord adOfflinePushRecord) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
            @Override
            public Integer getAdOfflinePushRecordByProvinceName(String provinceShortName, String orgPosition) {
                return 0;
            }
            @Override
            public Integer getAdOfflinePushRecordByYearMonth(String year, String month) {
                return 0;
            }
        };
    }
}
