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

export const apiPrefix = '/api/ad_manage/auth_manage/'
export function GetList(query: PageQuery) {
  return request({
    url: apiPrefix,
    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 genAdAuthLink(obj: any) {
    return request({
        url: '/api/ad_manage/auth/gen_adauth/',
        method: 'post',
        data: obj
    })
}

export function genSpAuthLink(auth_manage_id: number) {
    return request({
        url: '/api/ad_manage/auth/gen_adauth/',
        method: 'post',
        data: {
            auth_manage_id: auth_manage_id
        }
    })
}
