import { stringify } from 'qs';
import { request } from '@umijs/max';
import webpath from '@/utils/webPath';


export async function deleteByPrimaryKeyForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/delete?${stringify(params)}`);
}


export async function selectByPrimaryKeyForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/get?${stringify(params)}`);
}


export async function insertForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/insert`, {
        method: 'POST',
        data: {
            ...params,
            method: 'insert',
        },
    });
}


export async function updateForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/update`, {
        method: 'POST',
        data: {
            ...params,
            method: 'update',
        },
    });
}


export async function deleteByMapForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/deleteByMap`, {
        method: 'POST',
        data: {
            ...params,
            method: 'delete',
        },
    });
}


export async function updateByMapForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/updateByMap`, {
        method: 'POST',
        data: {
            ...params,
            method: 'update',
        },
    });
}


export async function getOneForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/getOne`, {
        method: 'POST',
        data: {
            ...params,
            method: 'fetch',
        },
    });
}



export async function getAllForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/getAll`, {
        method: 'POST',
        data: {
            ...params,
            method: 'fetch',
        },
    });
}


export async function queryPageForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/queryPage`, {
        method: 'POST',
        data: {
            ...params,
            method: 'fetch',
        },
    });
}


export async function countForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/count`, {
        method: 'POST',
        data: {
            ...params,
            method: 'fetch',
        },
    });
}

export async function insertBatchForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/insertBatch`, {
        method: 'POST',
        data: {
            ...params,
            method: 'insert',
        },
    });
}


export async function deleteBatchForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/deleteBatch`, {
        method: 'POST',
        data: {
            ...params,
            method: 'delete',
        },
    });
}


export async function updateBatchForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/updateBatch`, {
        method: 'POST',
        data: {
            ...params,
            method: 'update',
        },
    });
}

export async function materialFileUploadForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/materialFileUpload`, {
        method: 'POST',
        data: params.formdata,
        timeout: 120000
    });
}

export async function getMaterialVideo(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/materialVideo?${stringify(params)}`)
}


export async function downloadMaterialOtherForWxMaterial(params = {}) {
    return request(`/${webpath.portalwebpath}/web/api/service/wxmaterial/materialOther`, {
        method: 'POST',
        data: {
            ...params,
            method: 'fetch',
        },
        timeout: 120000,
        responseType: 'blob',
        // headers: { 'Content-Type': 'application/octet-stream' },
    });
}
