import { request } from '@umijs/max';


const httpPost = (url: string, data: any) => {
    return request(url, {
        method: 'POST',
        data: data
    })
}

const httpGet = (url: string, data: any) => {
    return request(url, {
        method: 'GET',
        params: data
    })
}


export const PostModel: Function = (url: string) => {
    return function (data: object) {
        return new Promise((resolve, reject) => {
            httpPost(url, data).then((res: any) => {
                console.log(res)
                if (res.code == 0) {
                    resolve(res)
                } else {
                    reject(res)
                }
            })
        })
    }
}

export const GetModel: Function = (url: string) => {
    return function (data: object) {
        return new Promise((resolve, reject) => {
            httpGet(url, data).then((res: any) => {
                if (res.code == 0) {
                    resolve(res)
                } else {
                    reject(res)
                }
            })
        })
    }
}

