package com.mosty.operation.log.aspect.feign;

import com.alibaba.fastjson.JSON;
import com.mosty.common.base.domain.ResponseResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *  操作日志feign客户端
 * @author kevin
 * @date 2022/2/4 8:38 PM
 * @since 1.0.0
 */
@Slf4j
@Component
public class OperationLogFallbackFactory implements FallbackFactory<OperationLogClient> {

    @Override
    public OperationLogClient create(Throwable throwable) {
        log.error("fallback", throwable);
        return sysOperLog -> {
            log.error("参数:sysOperLog:{}", JSON.toJSONString(sysOperLog));
            return ResponseResult.fail(null);
        };
    }
}
