package com.yuchen.saas.message.api.feign.xxl.fallback;

import com.yuchen.saas.message.api.dto.xxl.AddTaskCronDTO;
import com.yuchen.saas.message.api.dto.xxl.AddTaskDTO;
import com.yuchen.saas.message.api.dto.xxl.EditTaskCronDTO;
import com.yuchen.saas.message.api.dto.xxl.RemoveTaskCronDTO;
import com.yuchen.saas.message.api.feign.xxl.XxlJobServiceFeign;
import com.yuchen.saas.message.api.util.MessageFeignFallbackUtils;
import feign.hystrix.FallbackFactory;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.stereotype.Component;

/**
 * @author zhouhanwei
 * @create 2023/10/17 17:15
 */
@Component
public class XxlJobServiceFeignFallback implements FallbackFactory<XxlJobServiceFeign> {
    @Override
    public XxlJobServiceFeign create(Throwable throwable) {
        return new XxlJobServiceFeign() {

            @Override
            public R<Integer> pushCronJob(AddTaskDTO addTaskDTO) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R<Integer> pushCronJobV2(AddTaskCronDTO addTaskCronDTO) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R editTaskCron(EditTaskCronDTO editTaskCronDTO) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }

            @Override
            public R removeTask(RemoveTaskCronDTO removeTaskCronDTO) {
                return MessageFeignFallbackUtils.printLogAndReturn(throwable);
            }
        };
    }
}
