package com.jeeplus.sys.factory;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Lists;
import com.jeeplus.sys.domain.User;
import com.jeeplus.sys.feign.IUserApi;
import com.jeeplus.sys.service.dto.CertDTO;
import com.jeeplus.sys.service.dto.DataRuleDTO;
import com.jeeplus.sys.service.dto.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 用户服务降级处理
 *
 * @author jeeplus
 */
@Slf4j
@Component
public class UserApiFallbackFactory implements FallbackFactory <IUserApi> {
    @Override
    public IUserApi create(Throwable throwable) {
        log.error ( "用户服务调用失败:{}", throwable.getMessage ( ) );
        throwable.printStackTrace ( );
        return new IUserApi ( ) {
            public UserDTO getByLoginName(String loginName, String tenantId) {
                return null;
            }
            public UserDTO getByLoginNameNotTenantId(String loginName) {
                return null;
            }

            public void clearCache(UserDTO userDTO) {

            }

            public List <DataRuleDTO> getDataRuleList(UserDTO userDTO) {
                return Lists.newArrayList ( );
            }

            @Override
            public void updateUser(UserDTO userDTO) {

            }

            @Override
            public Set <String> getPermissions(String loginName) {
                return new HashSet <> ( );
            }

            @Override
            public UserDTO getByToken(String token) {
                return null;
            }

            @Override
            public UserDTO getById(String id) {
                return null;
            }

            @Override
            public String getByIdForXXL(String id) {
                return null;
            }

            @Override
            public UserDTO getFlowAbleById(String id) {
                return null;
            }

            @Override
            public List <UserDTO> findListByPostId(String postId) {
                return Lists.newArrayList ( );
            }

            @Override
            public List<UserDTO> getAllUserInfo() {
                return null;
            }

            @Override
            public List <UserDTO> findListFlowAbleByPostId(String postId) {
                return Lists.newArrayList ( );
            }

            @Override
            public List <UserDTO> findListByRoleId(String roleId) {
                return Lists.newArrayList ( );
            }

            @Override
            public List <UserDTO> findListByCompanyId(String companyId) {
                return Lists.newArrayList ( );
            }

            @Override
            public List <UserDTO> findListByOfficeId(String officeId) {
                return Lists.newArrayList ( );
            }

            @Override
            public boolean isEnableLogin(String tenantId, String username) {
                return true;
            }

            @Override
            public UserDTO getUserDTOByName(String name) {
                return null;
            }

            @Override
            public void updateUserUpPassword(UserDTO userDTO) {

            }

            @Override
            public String getSysParam(String parameter,String token) {
                return null;
            }

            @Override
            public List<CertDTO> getCertListByUserId() {
                return null;
            }

            @Override
            public String getFileDir(String url) {
                return null;
            }

            @Override
            public boolean delFile(String id) {
                return false;
            }

            @Override
            public List<UserDTO> getUserInfoByEnName(String enName) {
                return null;
            }

            @Override
            public List<User> selectListByName(String name) {
                return null;
            }

            @Override
            public List<User> getUserByOfficeAll(String operatorOffice) {
                return null;
            }

            @Override
            public IPage<UserDTO> findPage() {
                return null;
            }

            @Override
            public void saveOrUpdate(UserDTO userDTO) {

            }

            @Override
            public String enterpriseSearchByName(String keyword) {
                return null;
            }

            @Override
            public String enterpriseTicketInfoQueryById(String id) {
                return null;
            }

            @Override
            public String getUserIdByName(String name) {
                return null;
            }

        };
    }
}
