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

export const apiPrefix = '/api/ad_manage/sd-ad-product/report/'
export function GetList(query: UserPageQuery) {
  query['adGroupId'] = router.currentRoute.value.query.adGroupId
  return request({
    url: apiPrefix + 'list',
    method: 'get',
    params: query,
  })
}
export function GetObj(id: InfoReq) {
  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) {
  console.log('router123', router.currentRoute.value.query)
  query['adGroupId'] = router.currentRoute.value.query.adGroupId
  return request({
    url: apiPrefix + 'amount',
    method: 'GET',
    params: query,
  })
}

export function getLineData(query: UserPageQuery) {
  query['adGroupId'] = router.currentRoute.value.query.adGroupId
//   query['profileId'] = router.currentRoute.value.query.profileId
  return request({
    url: apiPrefix + 'trend/daily',
    method: 'GET',
    params: query,
  })
}
