const axios = require('axios')

export default {
    queryAllByTableName(tableName, callback) {
        axios.get('/api/metadata/tablename?tablename=' + tableName).then((response) => {
            callback(response);
        }).catch((error) => {
            console.error(error);
        })
    },
    queryAll(callback) {
        axios.get('/api/metadata').then((response) => {
            callback(response);
        }).catch((error) => {
            console.error(error);
        })
    },
    add(data, callback) {
        axios.post('/api/metadata/add', data).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error)
        })
    },
    update(data, callback) {
        axios.put('/api/metadata/update', data).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error)
        })
    },
    delete(data, callback) {
        axios.delete('/api/metadata/delete', {data: data}).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error)
        })
    },
    deleteAll(data, callback) {
        axios.delete('/api/metadata/deleteAll', {data: data}).then((response) => {
            callback(response);
        }).catch((error) => {
            console.log(error)
        })
    },
    queryPageable(data, page, size, callback) {
        axios.post('/api/metadata/queryPageable/' + page + '/' + size, data).then((response) => {
            callback(response);
        })
    },
    getTableNameList(callback) {
        axios.get('/api/metadata/getTableNameList').then((response) => {
            callback(response);
        })
    }
}