package com.sptg.statistics.api.feigns.fallback;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.statistics.api.dto.AppMemberLoginRecordsDto;
import com.sptg.statistics.api.entity.AppMemberLoginRecords;
import com.sptg.statistics.api.feigns.AppMemberLoginRecordsFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * title: AppMemberLoginRecordsFeignFallbackFactory
 * package: com.sptg.statistics.api.feigns.fallback
 * description:会员登录记录容错处理
 *
 *                
 *                
 */
@Component
@Slf4j
public class AppMemberLoginRecordsFeignFallbackFactory implements FallbackFactory<AppMemberLoginRecordsFeign> {

    @Override
    public AppMemberLoginRecordsFeign create(Throwable cause) {
        return new AppMemberLoginRecordsFeign() {
            @Override
            public ResultBean<Boolean> addAppMemberLoginRecords(AppMemberLoginRecords appMemberLoginRecords) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR,false);
            }

            @Override
            public ResultBean<List<Map<String,Object>>> getMemberLoginCountList(AppMemberLoginRecordsDto appMemberLoginRecordsDto) {
                log.error(cause.getMessage(),cause);
                return new ResultBean<>(ResultEnum.ERROR);
            }
        };
    }
}
