import { TenantForm, TenantQuery, TenantVO } from './types';

import { AxiosPromise } from 'axios';
import request from '@/utils/request';

// 查询租户列表
export function listTenant(query: any): AxiosPromise<TenantVO[]> {
  return request({
    url: '/system/tenant/list',
    method: 'post',
    data: query
  });
}

// 修改默认租户
export function updateSte(id: any): AxiosPromise<TenantVO[]> {
  return request({
    url: `/system/tenant/list` + id,
    method: 'post'
  });
}

// 提交
export function getTenantSub(id: any): AxiosPromise<TenantVO[]> {
  return request({
    url: '/system/tenant/submitSign/' + id,
    method: 'post'
  });
}
// 确认审核提交的状态
export function auditSubmit(id: any): AxiosPromise<TenantVO[]> {
  return request({
    url: '/system/tenant/confirmedSign/' + id,
    method: 'post'
  });
}

//审核提交的签约
export function auditTenant(data: any) {
  return request({
    url: '/system/tenant/reviewSubmitted',
    method: 'post',
    data: data
  });
}

// 获取比例套餐分成下拉表
export function getlistDivide(): AxiosPromise<TenantVO[]> {
  return request({
    url: '/system/commission-template/all',
    method: 'get'
  });
}

// 查询租户详细
export function getTenant(id: string | number): AxiosPromise<TenantVO> {
  return request({
    url: '/system/tenant/' + id,
    method: 'get'
  });
}

// 新增租户
export function addTenant(data: any) {
  return request({
    url: '/system/tenant/add',
    method: 'post',
    headers: {
      // isEncrypt: true // 加密传输
      validateRepeat: true // 校验重复提交
    },
    data: data
  });
}

// 修改租户
export function updateTenant(data: any) {
  return request({
    url: '/system/tenant/update',
    method: 'post',
    data: data
  });
}

// 租户状态修改
export function changeTenantStatus(id: string | number, tenantId: string | number, status: string) {
  const data = {
    id,
    tenantId,
    status
  };
  return request({
    url: '/system/tenant/changeStatus',
    method: 'put',
    data: data
  });
}

// 删除租户
export function delTenant(id: string | number | Array<string | number>) {
  return request({
    url: '/system/tenant/remove?ids=' + id,
    method: 'delete'
  });
}

// 动态切换租户
export function dynamicTenant(tenantId: string | number) {
  return request({
    url: '/system/tenant/dynamic/' + tenantId,
    method: 'get'
  });
}

// 清除动态租户
export function dynamicClear() {
  return request({
    url: '/system/tenant/dynamic/clear',
    method: 'get'
  });
}

// 同步租户套餐
export function syncTenantPackage(tenantId: string | number, packageId: string | number) {
  const data = {
    tenantId,
    packageId
  };
  return request({
    url: '/system/tenant/syncTenantPackage',
    method: 'get',
    params: data
  });
}

// 同步租户字典
export function syncTenantDict() {
  return request({
    url: '/system/tenant/syncTenantDict',
    method: 'get'
  });
}

// 租户封禁记录
export function getTenantBannelList(data) {
  return request({
    url: `/system/tenant/forbidden/list`,
    method: 'post',
    data: data
  });
}
