import request from '@/utils/request'

export function reCreateAdPlanConf(data) {
  return request({
    url: '/api/ad-plan-conf/reCreate',
    method: 'post',
    data
  })
}

export function generatePlan(data) {
  return request({
    url: '/api/ad-plan-conf/generate-plan',
    method: 'post',
    data
  })
}

export function reGeneratePlan(confId) {
  return request({
    url: `/api/ad-plan-conf/reGeneratePlan/${confId}`,
    method: 'get'
  })
}

export function syncSystemStatus(confId) {
  return request({
    url: `/api/ad-plan-conf/syncSystemStatus/${confId}`,
    method: 'get'
  })
}


/**
 * 创建广告计划配置
 * @param {Object} data 配置数据
 */
export function createAdPlanConf(data) {
  return request({
    url: '/api/ad-plan-conf/create',
    method: 'post',
    data
  })
}

/**
 * 更新广告计划配置
 * @param {Object} data 配置数据
 */
export function updateAdPlanConf(data) {
  return request({
    url: '/api/ad-plan-conf/update',
    method: 'post',
    data
  })
}

/**
 * 删除广告计划配置
 * @param {Number} confId 配置ID
 */
export function deleteAdPlanConf(confId) {
  return request({
    url: `/api/ad-plan-conf/${confId}`,
    method: 'delete'
  })
}

/**
 * 获取广告计划配置列表（分页）
 * @param {Number} pageNum 页码
 * @param {Number} pageSize 每页数量
 * @param {Object} params 查询参数
 */
export function getAdPlanConfList(pageNum = 1, pageSize = 10, params = {}) {
  return request({
    url: '/api/ad-plan-conf/list',
    method: 'get',
    params: { pageNum, pageSize, ...params }
  })
}

/**
 * 获取广告计划配置详情
 * @param {Number} confId 配置ID
 */
export function getAdPlanConfDetail(confId) {
  return request({
    url: `/api/ad-plan-conf/${confId}`,
    method: 'get'
  })
}

/**
 * 获取广告计划列表（分页）
 * @param {Number} confId 配置ID
 * @param {Number} accountId 账户ID（可选）
 * @param {Number} status 状态（可选）
 * @param {Number} pageNum 页码
 * @param {Number} pageSize 每页数量
 */
export function getAdPlanList(params) {
  return request({
    url: '/api/ad-plan/list',
    method: 'get',
    params
  })
}

/**
 * 获取广告计划创意列表
 * @param {Number} planId 计划ID
 */
export function getAdPlanCreativesByPlanId(planId) {
  return request({
    url: `/api/ad-plan-creative/plan/${planId}`,
    method: 'get'
  })
}

export function suspendByConfId(confId) {
  return request({
    url: `/api/ad-plan-conf/gdtSuspendByConfId`,
    params: { confId },
    method: 'get'
  })
}

export function deleteByConfId(confId) {
  return request({
    url: `/api/ad-plan-conf/gdtDeleteByConfId`,
    params: { confId },
    method: 'get'
  })
}

export function suspendByPlanIds(confId, ids) {
  return request({
    url: `/api/ad-plan-conf/gdtSuspendByPlanIds/${confId}`,
    method: 'post',
    data: ids
  })
}

export function deleteByPlanIds(confId, ids) {
  return request({
    url: `/api/ad-plan-conf/gdtDeleteByPlanIds/${confId}`,
    method: 'post',
    data: ids
  })
}

export function getOneCreativeImage(ids = []) {
  return request({
    url: '/api/ad-plan-conf/getOneCreativeImage',
    method: 'post',
    data: ids
  })
}

export function getOneBrandImage() {
  return request({
    url: '/api/ad-plan-conf/getOneBrandImage',
    method: 'get'
  })
}

export function getOneCreativeVideo(ids = []) {
  return request({
    url: '/api/ad-plan-conf/getOneCreativeVideo',
    method: 'post',
    data: ids
  })
}
