package com.sptg.video.cloud.api.feigns.fallback;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.video.cloud.api.dto.VCAccountDto;
import com.sptg.video.cloud.api.entity.VCAccount;
import com.sptg.video.cloud.api.feigns.VCAccountFeign;
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;

/**
 * @author zwx
 * @create 2020/10/16 11:50
 */
@Component
@Slf4j
public class VCAccountFeignFallbackFactory implements FallbackFactory<VCAccountFeign> {
    @Override
    public VCAccountFeign create(Throwable cause) {
        return new VCAccountFeign() {
            @Override
            public ResultBean<String> login(VCAccount account) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<Page<VCAccount>> pagingQuery(PageBean<VCAccount, VCAccountDto> pageBean) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<List<VCAccount>> getList() {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<String> updateBatch(List<VCAccount> vcAccountList) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
