import request from '@/utils/request';

// 查询租户分页列表
export function getTenantPage(query) {
  return request({
    url: '/system/tenant/page',
    method: 'get',
    params: query,
  });
}

// 查询租户详情
export function getTenantDetail(tenantId) {
  return request({
    url: `/system/tenant/${tenantId}`,
    method: 'get',
  });
}

// 查询租户所属用户分页列表
export function getTenantUserPage(query) {
  return request({
    url: '/system/tenant/user/page',
    method: 'get',
    params: query,
  });
}

// 新增租户
export function addTenant(data) {
  return request({
    url: '/system/tenant',
    method: 'post',
    data: data,
  });
}

// 修改租户
export function editTenant(data) {
  return request({
    url: '/system/tenant',
    method: 'put',
    data: data,
  });
}

// 删除租户
export function delTenant(tenantIdList) {
  return request({
    url: '/system/tenant',
    method: 'delete',
    data: Array.isArray(tenantIdList) ? tenantIdList : [tenantIdList],
  });
}

// 启用租户
export function enableTenant(tenantIdList) {
  return request({
    url: '/system/tenant/enable',
    method: 'put',
    data: Array.isArray(tenantIdList) ? tenantIdList : [tenantIdList],
  });
}

// 停用租户
export function disableTenant(tenantIdList) {
  return request({
    url: '/system/tenant/disable',
    method: 'put',
    data: Array.isArray(tenantIdList) ? tenantIdList : [tenantIdList],
  });
}

// 查询租户未绑定的用户列表
export function getUnbindTenantUserList(query) {
  return request({
    url: `/system/tenant/${query.tenantId}/unbind-users`,
    method: 'get',
    params: query,
  });
}

// 绑定租户用户
export function bindTenantUser(tenantId, userIdList) {
  return request({
    url: `/system/tenant/${tenantId}/bind-users`,
    method: 'post',
    data: userIdList,
  });
}

// 解绑租户用户
export function unbindTenantUser(tenantId, userIdList) {
  return request({
    url: `/system/tenant/${tenantId}/unbind-users`,
    method: 'post',
    data: userIdList,
  });
}

// 查询租户合同信息分页
export function getTenantContractPage(query) {
  return request({
    url: '/payment/contract/page',
    method: 'get',
    params: query,
  });
}

// 查询租户合同信息详情
export function getTenantContractDetail(id) {
  return request({
    url: `/payment/contract/${id}`,
    method: 'get',
  });
}

// 新增租户合同信息
export function addTenantContract(data) {
  return request({
    url: '/payment/contract',
    method: 'post',
    data,
  });
}

// 编辑租户合同信息
export function editTenantContract(data) {
  return request({
    url: '/payment/contract',
    method: 'put',
    data,
  });
}

// 编辑租户合同信息
export function delTenantContract(id) {
  return request({
    url: `/payment/contract/${id}`,
    method: 'delete',
  });
}

// 查询租户配置项详情列表
export function getTenantOptionDetailList(tenantId) {
  return request({
    url: `/system/tenant-option/detail-list/${tenantId}`,
    method: 'get',
  });
}

// 保存租户配置项详情列表
export function saveTenantOptionDetailList(data) {
  return request({
    url: '/system/tenant-option/detail-list',
    method: 'post',
    data,
  });
}

// 查询租户配置项前端form表单列表
export function getTenantOptionFormList() {
  return request({
    url: '/system/tenant-option/form-list',
    method: 'get',
  });
}
