
import http from "@/utils/request"
import common from "@/utils/common"

export default {
    management: {},
    post: async function (method, datas, baseURL = "/api") {
        var res = await http.post({
            "jsonrpc": "2.0",
            "id": common.guid(),
            "method": method,
            "params": [datas]
        }, "/", { baseURL: baseURL });
        return res;
    },
    get: async function (method, datas, baseURL = "/api") {
        return await http.get({
            "jsonrpc": "2.0",
            "id": common.guid(),
            "method": method,
            "params": [datas]
        }, "/", { baseURL: baseURL });
    },
    list: async function (method, datas, baseURL = "/api") {
        if (!datas.PageIndex) {
            datas.PageIndex = datas.page;
        }
        var res = await http.post({
            "jsonrpc": "2.0",
            "id": common.guid(),
            "method": method,
            "params": [datas]
        }, "/", { baseURL: baseURL });
        var formatterData = {
            total: res.TotalCount,
            rows: res.PageData,
            page: res.PageIndex,
            pageSize: res.PageSize
        };
        return formatterData;
    }
}
