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

/**
 * 查询
 * @param tableName
 * @param data
 * @returns
 */
export function queryData(tableName: string, data: any) {
  return apiRequest({
    url: '/daas/data/table/select/{tableName}',
    method: 'GET',
    params: data,
  })
}

/**
 * 添加
 * @param tableName
 * @param data
 * @returns
 */
export function insertData(tableName: string, data: any) {
  return apiRequest({
    url: '/daas/data/table/insert/{tableName}',
    method: 'POST',
    data,
  })
}

/**
 * 更新
 * @param tableName
 * @param data
 * @returns
 */
export function updateData(tableName: string, data: any) {
  return apiRequest({
    url: '/daas/data/table/update/{tableName}',
    method: 'PUT',
    data,
  })
}

/**
 * 删除
 * @param tableName
 * @param data
 * @returns
 */
export function deleteData(tableName: string, data: any) {
  return apiRequest({
    url: `/daas/data/table/delete/${tableName}`,
    method: 'DELETE',
    data,
  })
}

/**
 * 执行SQL
 * @param data
 * @returns
 */
export function execSql(data: object) {
  return apiRequest({
    url: '/daas/data/execSql',
    method: 'POST',
    data,
  })
}
