import { request } from '/@/utils/service';
import { UserPageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
import XEUtils from 'xe-utils';

export const apiPrefix = '/api/ad_manage/sdtarget/report/';
export function GetList(query: UserPageQuery) {
    query["tactic"] = "T00020"
    return request({
        url: '/api/ad_manage/sdtarget/',
        method: 'get',
        params: query,
    })
}
export function GetObj(id: any) {
    return request({
        url: apiPrefix + id + "/",
        method: 'get',
    });
}

export function AddObj(obj: AddReq) {
    return request({
        url: apiPrefix,
        method: 'post',
        data: obj,
    });
}

export function UpdateObj(obj: EditReq) {
    return request({
        url: apiPrefix + obj.id + '/',
        method: 'put',
        data: obj,
    });
}

export function DelObj(id: DelReq) {
    return request({
        url: apiPrefix + id + '/',
        method: 'delete',
        data: { id },
    });
}

export function getCardData(query: UserPageQuery) {
    query["tactic"] = "T00020"
    return request({
        url: apiPrefix + "amount",
        method: 'GET',
        params: query
    })
}

export function getLineData(query: UserPageQuery) {
    query["tactic"] = "T00020"
    return request({
        url: apiPrefix + "trend/daily",
        method: 'GET',
        params: query
    })
}

export function getLineWeekData(query: UserPageQuery) {
    query["tactic"] = "T00020"
    return request({
        url: apiPrefix + "trend/weekly",
        method: 'GET',
        params: query
    })
}

export function getLineMonthData(query: UserPageQuery) {
    query["tactic"] = "T00020"
    return request({
        url: apiPrefix + "trend/monthly",
        method: 'GET',
        params: query
    })
}

export function getAdStructureData(query: UserPageQuery) {
    return request({
        url: apiPrefix + "structure",
        method: 'GET',
        params: query
    })
}
