import request from '@/utils/request'

//获取当前租户信息
export function tenantInfo() {
  return request({
    url: '/system/tenant/getTenant',
    method: 'get'
  })
}

// 获取我加入的租户列表
export function getOwnJoinTenants() {
  return request({
    url: '/system/tenant/getOwnJoinTenants',
    method: 'get'
  })
}

// 获取我创建的租户列表
export function getOwnCreateTenants() {
  return request({
    url: '/system/tenant/getOwnCreateTenants',
    method: 'get'
  })
}

// 使用用户名，获得租户编号
export function getTenantIdByName(username) {
  return request({
    url: '/system/auth/getCurrentTenantIdByUsername',
    method: 'get',
    params: {
      username
    }
  })
}

// 创建租户
export function createTenant(data) {
  return request({
    url: '/system/tenant/create',
    method: 'post',
    data: data
  })
}
// 加入租户
export function joinTenant(data) {
  return request({
    url: '/system/tenant/join',
    method: 'post',
    data: data
  })
}

// 切换租户
export function changeTenant(data) {
  return request({
    url: '/system/tenant/change',
    method: 'put',
    data: data
  })
}

// 更新租户
export function updateTenant(data) {
  return request({
    url: '/system/tenant/update',
    method: 'put',
    data: data
  })
}

// 删除租户
export function deleteTenant(id) {
  return request({
    url: '/system/tenant/delete?id=' + id,
    method: 'delete'
  })
}

// 获得租户
export function getTenant(id) {
  return request({
    url: '/system/tenant/get?id=' + id,
    method: 'get'
  })
}

// 获得租户分页
export function getTenantPage(query) {
  return request({
    url: '/system/tenant/page',
    method: 'get',
    params: query
  })
}

// 导出租户 Excel
export function exportTenantExcel(query) {
  return request({
    url: '/system/tenant/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}
