package com.vctgo.system.api.factory;

import com.vctgo.common.core.domain.R;
import com.vctgo.system.api.RemoteProfileService;
import com.vctgo.system.api.domain.ProfileCoreExperience;
import com.vctgo.system.api.domain.ProfileLabel;
import com.vctgo.system.api.domain.SysPlatformUser;
import com.vctgo.system.api.domain.dto.ProfileActivityCaseDto;
import com.vctgo.system.api.domain.dto.ProfileUserInfoDto;
import com.vctgo.system.api.domain.dto.SysBranchKindergartenDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 文件服务降级处理
 *
 * @author vctgo
 */
@Component
public class RemoteProfileFallbackFactory implements FallbackFactory<RemoteProfileService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteProfileFallbackFactory.class);

    @Override
    public RemoteProfileService create(Throwable throwable) {
        log.error("内部资料服务调用失败:{}", throwable.getMessage());
        return new RemoteProfileService() {

            @Override
            public R<ProfileUserInfoDto> getValidUserInfoByUserId(Long userId){
                return R.fail("获取资料用户详细信息失败:" + throwable.getMessage());
            }

            @Override
            public R<String> deleteProfileUser(Long[] userIds) {
                return R.fail("操作资料用户详细信息失败:" + throwable.getMessage());
            }

            @Override
            public R<String> modifyUserInfo(SysPlatformUser sysPlatformUser) {
                return R.fail("同步“内部资源服务”用户信息失败:" + throwable.getMessage());
            }

            @Override
            public R<String> modifyKindergartenInfo(SysBranchKindergartenDto sysBranchKindergartenDto) {
                return R.fail("同步“内部资源服务”园所信息失败:" + throwable.getMessage());
            }

            @Override
            public R<List<ProfileLabel>> getProfileLabelList(List<Long> labelIdList) {
                return R.fail("获取标签信息失败" + throwable.getMessage());
            }

            @Override
            public R<List<ProfileCoreExperience>> getCoreExperience(List<Long> coreIdList) {
                return R.fail("获取核心经验失败" + throwable.getMessage());
            }

            @Override
            public R<List<ProfileActivityCaseDto>> getCaseByBookIdList(String materialType, String bookIdList) {
                return R.fail("获取取活动案例列表失败" + throwable.getMessage());
            }
        };
    }
}
