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


/**
 * 新增定向
 * @param data 
 * @returns 
 */
export async function addTargetingApi(data: any) {
    return request(api + `/adq/v3/targeting/add`, {
        method: 'POST',
        data: [data]
    })
}

/**
 * 修改定向
 * @param data 
 * @returns 
 */
export async function updateTargetingApi(data: any) {
    return request(api + `/adq/v3/targeting/update`, {
        method: 'POST',
        data
    })
}


/**
 * 校验定向
 * @param data 
 * @returns 
 */
export async function checkTargetingApi(data: any) {
    return request(api + `/adq/v3/targeting/check`, {
        method: 'POST',
        data: [data]
    })
}


/**
 * 删除定向
 * @param data 
 * @returns 
 */
export async function delTargetingApi(params: { id: number }) {
    return request(api + `/adq/v3/targeting/delete`, {
        method: 'POST',
        params
    })
}

/**
 * 获取云端列表 ,也要分页
 * @param data 
 * @returns 
 */
export async function getTargetingRemoteListApi(data: PULLIN.GetTargeting) {
    return request(api + `/adq/v3/targeting/remoteList`, {
        method: 'POST',
        data
    })
}

/**
 * 分页查询定向模板
 * @param data 
 * @returns 
 */
export async function getTargetingListApi(data: PULLIN.GetTargeting) {
    return request(api + `/adq/v3/targeting/list`, {
        method: 'POST',
        data
    })
}

/**
 * 创建任务
 * @param data 
 * @returns 
 */
export async function createAdgroupTaskApi(data: any) {
    return request(api + `/adq/v3/adgroup/createAdgroupTask`, {
        method: 'POST',
        data
    })
}

/**
 * 多类型创建任务
 * @param data 
 * @returns 
 */
export async function createAdgroupTaskV2Api(data: any) {
    return request(api + `/adq/v3/adgroup/createAdgroupTaskV2`, {
        method: 'POST',
        data
    })
}

export async function getTaskV3ListApi(data: PULLIN.GetTaskV3Props) {
    return request(api + `/adq/v3/adgroup/selectByPage`, {
        method: 'POST',
        data
    })
}

/**
 * 中止任务
 * @param data 
 * @returns 
 */
export async function stopAdgroupTaskApi(data: number[]) {
    return request(api + `/adq/v3/adgroup/stopAdgroupTask`, {
        method: 'POST',
        data
    })
}

/**
 * 获取详情
 * @param id 
 * @returns 
 */
export async function getSelectTaskDetailApi(id: number) {
    return request(api + `/adq/v3/adgroup/selectTaskDetail/${id}`, {
        method: 'GET'
    })
}

/**
 * 任务日志
 * @param data 
 * @returns 
 */
export async function getTaskV3LogListApi(data: PULLIN.GetTaskV3LogProps) {
    return request(api + `/adq/v3/adgroup/selectAdgroupLog`, {
        method: 'POST',
        data
    })
}

/**
 * 任务执行记录
 * @param data 
 * @returns 
 */
export async function getSelectAdTaskLogListApi(data: PULLIN.GetTaskV3LogProps) {
    return request(api + `/adq/v3/adgroup/selectAdTaskLog`, {
        method: 'POST',
        data
    })
}

/**
 * 查询创意创建日志
 * @param data 
 * @returns 
 */
export async function getDynamicListApi(data: PULLIN.GetDynamicV3LogProps) {
    return request(api + `/adq/v3/adgroup/selectCreativesCreateLog`, {
        method: 'POST',
        data
    })
}

/**
 * 批量添加创意
 * @param data 
 * @returns 
 */
export async function createDynamicTaskApi(data: any) {
    return request(api + `/adq/v3/adgroup/batchCreateCreative`, {
        method: 'POST',
        data
    })
}


/************策略组*************/
/**
 * 添加策略组
 * @param data 
 * @returns 
 */
export async function addV3StrategyApi(data: PULLIN.AddV3StrategyProps) {
    return request(api + `/adq/v3/strategy/add`, {
        method: 'POST',
        data
    })
}

/**
 * 策略组更新
 * @param data 
 * @returns 
 */
export async function editV3StrategyApi(data: PULLIN.AddV3StrategyProps) {
    return request(api + `/adq/v3/strategy/update`, {
        method: 'POST',
        data
    })
}

/**
 * 获取策略组列表
 * @param params 
 * @returns 
 */
export async function getV3StrategyListApi(params: PULLIN.GetV3StrategyListProps) {
    return request(api + `/adq/v3/strategy/list`, {
        method: 'GET',
        params
    })
}

/**
 * 删除
 * @param strategyId 
 * @returns 
 */
export async function delV3StrategyApi(strategyId: number) {
    return request(api + `/adq/v3/strategy/delete/${strategyId}`, {
        method: 'POST'
    })
}

/**
 * 批量复制落地页
 * @param data 
 * @returns 
 */
export async function batchCreateDownPageApi(data: { accountId: number, pageName: string, templateId: number, downPageMaterialDTOS: { imageId?: number[], materialType: number, videoId: number }[] }) {
    return request(api + `/adq/v3/marketingAssets/batchCreateDownPage`, {
        method: 'POST',
        data
    })
}

/*******************/

/**
 * 策略
 * @param data 
 * @returns 
 */
export async function addOnlyDataApi(data: { type: string, data: string }) {
    return request(api + `/adq/v3/strategy/only/add`, {
        method: 'POST',
        data
    })
}

/**
 * 获取策略
 * @param data 
 * @returns 
 */
export async function getOnlyDataApi(params: { type: string }) {
    return request(api + `/adq/v3/strategy/only/getOne`, {
        method: 'GET',
        params
    })
}