import http from '@/utils/request'

const dataService = {
  // 获取数据产品列表
  getProducts (params) {
    return http.get('/dataservice/products', params)
  },

  // 获取数据产品详情
  getProductDetail (productId) {
    return http.get(`/dataservice/products/${productId}`)
  },

  // 获取数据预览
  getProductPreview (productId, limit = 200) {
    return http.get(`/dataservice/products/${productId}/preview`, {
      limit
    })
  },

  // 下载 Excel (返回 Blob)
  downloadExcel (productId, limit = 200) {
    return http.getDownload(`/dataservice/products/${productId}/download`, {
      limit
    })
  },

  // 标记为已查看
  markAsViewed (productId) {
    return http.post(`/dataservice/products/${productId}/viewed`)
  },

  // 刷新统计信息
  refreshStats (productId) {
    return http.post(`/dataservice/products/${productId}/refresh`)
  },

  // 删除数据产品
  deleteProduct (productId) {
    return http.del(`/dataservice/products/${productId}`)
  },

  // 注册数据产品
  registerProduct (data) {
    return http.post('/dataservice/products', data)
  },

  // 加工数据可视化
  getVisualizeData (productId, data) {
    return http.post(`/dataservice/products/${productId}/lineage-visualization`, data)
  }
}

export const api = dataService
