// API接口定义
var API = {
    // ========== 系统配置 ==========
    getConfig: function() {
        return axios.get('source/getConfig');
    },

    // ========== 数据同步相关 ==========
    exportData: function(date) {
        var params = date ? { date: date } : {};
        return axios.get('source/export', { params: params });
    },

    importData: function(date) {
        var params = date ? { date: date } : {};
        return axios.get('source/import', { params: params });
    },

    testSync: function() {
        return axios.get('source/test');
    },

    testSyncR: function() {
        return axios.get('source/testR');
    },

    getRemoteFiles: function() {
        return axios.get('source/getRemoteAll');
    },

    cleanTwo: function(days) {
        return axios.get('source/removeTwo', { params: { a: days } });
    },

    cleanThree: function(days) {
        return axios.get('source/removeThree', { params: { a: days } });
    },

    // ========== 同步表配置相关 ==========
    getTablePage: function(params) {
        return axios.get('/api/sync-table-config/page', { params: params });
    },

    getTableList: function() {
        return axios.get('/api/sync-table-config/list');
    },

    getTableById: function(tableName) {
        return axios.get('/api/sync-table-config/' + tableName);
    },

    addTable: function(data) {
        return axios.post('/api/sync-table-config', data);
    },

    updateTable: function(data) {
        return axios.put('/api/sync-table-config', data);
    },

    deleteTable: function(tableName) {
        return axios.delete('/api/sync-table-config/' + tableName);
    },

    deleteTables: function(tableNames) {
        return axios.delete('/api/sync-table-config/batch', { data: tableNames });
    },

    updateTableStatus: function(tableName, enabled) {
        return axios.put('/api/sync-table-config/status/' + tableName, null, {
            params: { enabled: enabled }
        });
    }
};