package com.yuchen.saas.message.api.feign.notice;

import com.yuchen.saas.message.api.dto.PmgBatNoticeQueryDto;
import com.yuchen.saas.message.api.util.MessageFeignFallbackUtils;
import com.yuchen.saas.message.api.vo.PmgBatNoticeListVo;
import com.yuchen.saas.message.api.vo.PmgBatNoticeVo;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 公告/资讯feign调用
 * </p>
 *
 * @author caiwq
 * @since 2024-02-28
 */
@Component
public class NoticeFeignFallback implements FallbackFactory<NoticeFeignServer> {

    @Override
    public NoticeFeignServer create(Throwable throwable) {
        return new NoticeFeignServer() {

            @Override
            public R<PmgBatNoticeVo> getNoticeById(Long id) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<NestPage<PmgBatNoticeListVo>> getNoticePageList(PmgBatNoticeQueryDto queryDto) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
