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

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.fallback.XxlJobServiceFeignFallback;
import org.nest.springwrap.core.launch.app.AppNameConstant;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author zhouhanwei
 * @create 2023/10/17 17:14
 */
@FeignClient(
        value = AppNameConstant.SAAS_MESSAGE,
        fallbackFactory = XxlJobServiceFeignFallback.class
)
public interface XxlJobServiceFeign {

    @PostMapping("/xxlJob/push/addTask")
    R<Integer> pushCronJob(@Validated @RequestBody AddTaskDTO addTaskDTO);

    /**
     * 发送任务-按cron表达式触发
     * @param addTaskCronDTO 入参
     * @return 返回结果
     */
    @PostMapping("/xxlJob/push/addTaskCron")
    R<Integer> pushCronJobV2(@Validated @RequestBody AddTaskCronDTO addTaskCronDTO);

    /**
     * 编辑任务-按cron表达式触发
     * @param editTaskCronDTO 入参
     * @return 返回结果
     */
    @PostMapping("/xxlJob/push/editTaskCron")
    R editTaskCron(@Validated @RequestBody EditTaskCronDTO editTaskCronDTO);

    /**
     * 编辑任务-按cron表达式触发
     * @param removeTaskCronDTO 入参
     * @return 返回结果
     */
    @PostMapping("/xxlJob/push/removeTask}")
    R removeTask(@Validated @RequestBody RemoveTaskCronDTO removeTaskCronDTO);
}
