import apiRequest from '@/network/http/apiRequest'

/**
 * 获取Api分页
 * @param data
 * @returns
 */
export function getApiByPage(data: any) {
  return apiRequest({
    url: '/paas/api/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 获取Api列表
 * @param data
 * @returns
 */
export function getApiByList(data: any) {
  return apiRequest({
    url: '/paas/api',
    method: 'GET',
    params: data,
  })
}

/**
 * 根据Id获取Api
 * @param apiId
 * @returns
 */
export function getApiById(modId: number, apiId: number) {
  return apiRequest({
    url: `/paas/api/${modId}/${apiId}`,
    method: 'GET',
  })
}

/**
 * 添加Api
 * @param data
 * @returns
 */
export function createApi(data: any) {
  return apiRequest({
    url: '/paas/api/add',
    method: 'POST',
    data,
  })
}

/**
 * 更新Api
 * @param data
 * @returns
 */
export function updateApi(data: any) {
  return apiRequest({
    url: '/paas/api/update',
    method: 'PUT',
    data,
  })
}

/**
 * 更新Api
 * @param apiId
 * @param status
 * @returns
 */
export function updateApiStatus(modId: number, apiId: number, status: number) {
  return apiRequest({
    url: `/paas/api/updateStatus/${modId}/${apiId}/${status}`,
    method: 'PUT',
  })
}

/**
 * 删除Api
 * @param apiId
 * @returns
 */
export function deleteApiById(apiId: number) {
  return apiRequest({
    url: `/paas/api/${apiId}`,
    method: 'DELETE',
  })
}
