const axios = require('axios');
export default {
    queryPageable(index, size, dataBody, callback) {
        axios.post('/api/task/queryPageable/' + index + '/' + size, dataBody).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error);
        })
    },
    queryTaskByIds(ids, callback) {
        axios.post('/api/task/getTaskByIds', ids).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error);
        })
    },
    delTasks(data, callback) {
        axios.delete('/api/task', {data: data}).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error)
        })
    },
    queryTaskStatus(ids, callback) {
        axios.post('/api/task/status', ids).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error);
        })
    },
    startTasks(ids, callback) {
        axios.post('/api/task/schedule/start', ids).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error);
        })
    },
    runSingleTasks(ids, callback) {
        axios.post('/api/task/schedule/single', ids).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error);
        })
    },
    saveTask(task, isEdit, callback) {
        if (isEdit) {
            axios.put('/api/task', task).then((response) => {
                callback(response);
            }).catch((error) => {
                console.log(error);
            })
        } else {
            axios.post('/api/task', task).then((response) => {
                callback(response);
            }).catch((error) => {
                console.log(error);
            })
        }
    }
}