import { request } from 'umi';
import { api } from '../api';

/**
 * 广告列表
 * @param data 
 * @returns 
 */
export async function getAdqV3AdListApi(data: ADQV3.GetAdListProps) {
    return request(api + '/adq/adgroup/listOfPage', {
        method: 'POST',
        data
    });
}

/**
 * 广告详情
 * @param param0 
 * @returns 
 */
export async function getAdgroupDetailApi({ accountId, adgroupId }: ADQV3.GetAdgroupDetailProps) {
    return request(api + `/adq/adgroup/detail/${accountId}/${adgroupId}`, {
        method: 'GET'
    });
}

/**
 * 同步
 * @param data 
 * @returns 
 */
export async function syncBatchApi(data: ADQV3.AccountAdgroupMapsProps) {
    return request(api + '/adq/adgroup/syncBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 启停
 * @param data 
 * @returns 
 */
export async function modifyStatusBatchApi(data: ADQV3.ModifyStatusBatchProps) {
    return request(api + '/adq/adgroup/modifyStatusBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 出价
 * @param data 
 * @returns 
 */
export async function modifyAmountBatchApi(data: ADQV3.ModifyAmountBatchProps) {
    return request(api + '/adq/adgroup/modifyAmountBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 3.0创意
 * @param data 
 * @returns 
 */
export async function getDynamicCreativeV3ListApi(data: ADQV3.GetDynamicCreativeProps) {
    return request(api + '/adq/dynamicCreative/listOfPage', {
        method: 'POST',
        data
    });
}

/**
 * 修改落地页
 * @param data 
 * @returns 
 */
export async function batchUpdateDownloadApi(data: ADQV3.BatchUpdateDownloadProps[]) {
    return request(api + '/adq/dynamicCreative/batchUpdateDownload', {
        method: 'POST',
        data
    });
}

/**
 * 修改时间
 * @param data 
 * @returns 
 */
export async function modifyAdTimeBatchApi(data: ADQV3.ModifyAdTimeBatchProps) {
    return request(api + '/adq/adgroup/modifyAdTimeBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 修改广告信息 名称
 * @param data 
 * @returns 
 */
export async function updateBatchAdgroupInfoApi(data: ADQV3.UpdateBatchAdgroupInfoProps) {
    return request(api + '/adq/adgroup/updateBatchAdgroupInfo', {
        method: 'PUT',
        data
    });
}

/**
 * 修改广告日限额
 * @param data 
 * @returns 
 */
export async function modifyDailyBudgetBatchApi(data: ADQV3.ModifyDailyBudgetBatchProps) {
    return request(api + '/adq/adgroup/modifyDailyBudgetBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 删除广告
 * @param data 
 * @returns 
 */
export async function delBatchApi(data: ADQV3.AccountAdgroupMapsProps) {
    return request(api + '/adq/adgroup/delBatch', {
        method: 'PUT',
        data
    });
}

/**
 * 删除创意
 * @param data 
 * @returns 
 */
export async function delBatchCreativeApi(data: ADQV3.AccountAdgroupMapsProps) {
    return request(api + '/adq/adgroup/delBatchCreative', {
        method: 'PUT',
        data
    });
}

/**
 * 批量修改创意信息
 * @param data 
 * @returns 
 */
export async function updateBatchDynamicCreativesInfoApi(data: ADQV3.ModifyStatusBatchProps) {
    return request(api + '/adq/adgroup/updateBatchDynamicCreativesInfo', {
        method: 'PUT',
        data
    });
}

/**
 * 批量提交复审
 * @param data 
 * @returns 
 */
export async function retrialBatchApi(data: ADQV3.RetrialBatchProps) {
    return request(api + '/adq/adgroup/retrialBatch', {
        method: 'POST',
        data
    });
}

/**
 * 同步创意
 * @param data 
 * @returns 
 */
export async function syncBatchCreativeApi(data: ADQV3.AccountAdgroupMapsProps) {
    return request(api + '/adq/adgroup/syncBatchCreative', {
        method: 'PUT',
        data
    });
}


/**
 * 创意操作日志列表
 * @param data 
 * @returns 
 */
export async function dynamicCreativeLogApi(data: ADQV3.DynamicCreativeLogProps) {
    return request(api + '/adq/dynamicCreative/operate/log', {
        method: 'POST',
        data
    });
}

/**
 * 新增任务
 * @param data 
 * @returns 
 */
export async function addTaskAutoAcquisitionApi(data: ADQV3.AddTaskAutoAcquisitionProps) {
    return request(api + '/adq/adgroupQuant/task/add', {
        method: 'POST',
        data
    });
}

/**
 * 修改
 * @param data 
 * @returns 
 */
export async function updateTaskAutoAcquisitionApi(data: ADQV3.AddTaskAutoAcquisitionProps) {
    return request(api + '/adq/adgroupQuant/task/modifyById', {
        method: 'POST',
        data
    });
}

/**
 * 立即执行
 * @param data 
 * @returns 
 */
export async function addOnceTaskAutoAcquisitionApi(data: ADQV3.AddTaskAutoAcquisitionProps) {
    return request(api + '/adq/adgroupQuant/task/add/once', {
        method: 'POST',
        data
    });
}


/**
 * 查询一键起量任务列表
 * @param data 
 * @returns 
 */
export async function getAdgroupQuantTaskListApi(data: ADQV3.GetAdgroupQuantTaskListProps) {
    return request(api + '/adq/adgroupQuant/task/listOfPage', {
        method: 'POST',
        data
    });
}

/**
 * 删除任务
 * @param params 
 * @returns 
 */
export async function delAdgroupQuantTaskApi(params: {id: number}) {
    return request(api + '/adq/adgroupQuant/task/delete', {
        method: 'DELETE',
        params
    });
}


/**
 * 一键起量广告日志-分页查询任务的广告执行日志
 * @param data 
 * @returns 
 */
export async function getAdgroupQuantTaskAdLogListApi(data: ADQV3.GetAdgroupQuantTaskAdLogListProps) {
    return request(api + '/adq/adgroupQuant/adLog/listOfPage', {
        method: 'POST',
        data
    });
}

/**
 * 一键起量广告-从任务中批量删除广告
 * @param data 
 * @returns 
 */
export async function delAdgroupQuantTaskAdApi(data: ADQV3.DelAdgroupQuantTaskAdProps) {
    return request(api + '/adq/adgroupQuant/ad/removeFromTask', {
        method: 'POST',
        data
    });
}

/**
 * 一键起量广告-分页查询任务关联的广告列表
 * @param data 
 * @returns 
 */
export async function getAdgroupQuantTaskAdDetailsListApi(data: ADQV3.GetAdgroupQuantTaskAdDetailsListProps) {
    return request(api + '/adq/adgroupQuant/ad/listOfPage', {
        method: 'POST',
        data
    });
}

/**
 * 所有任务列表
 * @returns 
 */
export async function getTaskAllListApi() {
    return request(api + '/adq/adgroupQuant/task/all', {
        method: 'GET'
    });
}

/**
 * 添加到任务
 * @param data 
 * @returns 
 */
export async function adAddTaskApi(data: ADQV3.AdAddTaskProps) {
    return request(api + '/adq/adgroupQuant/ad/addToTask', {
        method: 'POST',
        data
    });
}