package com.sptg.permissions.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.permissions.api.dto.AccountDto;
import com.sptg.permissions.api.entity.DeviceAdminUser;
import com.sptg.permissions.api.feigns.DeviceAdminUserFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * title: DeviceAdminUserFeignFallbackFactory
 * description:
 *
 *                  
 *            
 */
@Slf4j
@Component
public class DeviceAdminUserFeignFallbackFactory implements FallbackFactory<DeviceAdminUserFeign> {

    @Override
    public DeviceAdminUserFeign create(Throwable cause) {
        return new DeviceAdminUserFeign(){
            @Override
            public DeviceAdminUser getUserById(Long userId) {
                log.error(cause.getMessage());
                return null;
            }

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

            @Override
            public ResultBean<Boolean> addEntity(DeviceAdminUser user) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }

            @Override
            public ResultBean<DeviceAdminUser> login(DeviceAdminUser user) {
                log.error(cause.getMessage());
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
