import { request } from 'umi';
import BaseService from '@/utils/BaseService';
import SystemConst from '@/utils/const';
import type { AccessItem } from './typings';

class Service extends BaseService<AccessItem> {
  public queryGatewayDetail = (data: any) =>
    request(`/${SystemConst.API_BASE}/gateway/device/detail/_query`, {
      method: 'POST',
      data,
    });
  public queryList = (data: any) =>
    request(`/${SystemConst.API_BASE}/gateway/device/detail/_query`, {
      method: 'POST',
      data,
    });
  public startUp = (id: string) =>
    request(`/${SystemConst.API_BASE}/gateway/device/${id}/_startup`, {
      method: 'POST',
    });
  public shutDown = (id: string) =>
    request(`/${SystemConst.API_BASE}/gateway/device/${id}/_shutdown`, {
      method: 'POST',
    });
  public getProviders = () =>
    request(`/${SystemConst.API_BASE}/gateway/device/providers`, {
      method: 'GET',
    });
  public getNetworkList = (networkType: string, params?: any) =>
    request(`/${SystemConst.API_BASE}/network/config/${networkType}/_alive`, {
      method: 'GET',
      params,
    });
  public getProtocolList = (transport?: string, params?: any) => {
    return request(`/${SystemConst.API_BASE}/protocol/supports/${transport ? transport : ''}`, {
      method: 'GET',
      params,
    });
  };
  public getChildConfigView = (id: string) => {
    return request(`/${SystemConst.API_BASE}/protocol/${id}/transports`, {
      method: 'GET',
    });
  };
  public getConfigView = (id: string, transport: string) =>
    request(`/${SystemConst.API_BASE}/protocol/${id}/transport/${transport}`, {
      method: 'GET',
    });

  public getClusters = () =>
    request(`/${SystemConst.API_BASE}/network/resources/clusters`, {
      method: 'GET',
    });
  //引导页-不在提示
  public productGuide = () =>
    request(`/${SystemConst.API_BASE}/user/settings/product/guide`, {
      method: 'GET',
    });
  public productGuideSave = (data: any) =>
    request(`/${SystemConst.API_BASE}/user/settings/product/guide`, {
      method: 'PATCH',
      data,
    });
  public productGuideDetail = () =>
    request(`/${SystemConst.API_BASE}/user/settings/product/guide`, {
      method: 'DELETE',
    });
  public getResourcesCurrent = () =>
    request(`${SystemConst.API_BASE}/network/resources/alive/_current`, {
      method: 'GET',
    });
}

export default Service;
