index.ts 1.62 KB
 import { defHttp } from '@/utils/external/http/axios';
import { DeviceAttributesRecord, GetDeviceListParams, PublicInterfaceRecord } from './model';
import { PaginationResult } from '/#/external/axios';

enum Api {
  PUBLIC_API = '/data_view_interface',
  ORG_LISt = '/organization/me/list',
  DEVICE_PROFILE_LIST = '/device_profile/me/list',
  DEVICE_LIST = '/device/list',
  DEVICE_ATTR_LIST = '/device/attributes',
  GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find_all_interface',
  GET_PUBLIC_INTERFACE_DETAIL = '/data_view_interface/get_interface_details'
}

export const getPublicInterface = async (params: Record<'page' | 'pageSize', number>) => {
  return defHttp.get<PaginationResult<PublicInterfaceRecord>>({
    url: Api.PUBLIC_API,
    params
  })
}

export const getOrgList = async () => {
  return defHttp.get({
    url: Api.ORG_LISt
  })
}

export const getDeviceProfileList = async (params?: Record<'deviceType', string>) => {
  return defHttp.get({
    url: Api.DEVICE_PROFILE_LIST,
    params
  })
}

export const getDeviceList = async (params?: GetDeviceListParams) => {
  return defHttp.get({
    url: Api.DEVICE_LIST,
    params
  })
}

export const getDeviceAttrList = async (deviceProfileId: string) => {
  return defHttp.get<DeviceAttributesRecord[]>({
    url: `${Api.DEVICE_ATTR_LIST}/${deviceProfileId}`
  })
}


export const getDeviceInterfaceDetail = async (interfaces: string[]) => {
  return defHttp.get({
    url: Api.GET_PUBLIC_INTERFACE_DETAIL,
    params: interfaces
  })
}

export const getAllPublicInterface = async () => {
  return defHttp.get<PublicInterfaceRecord[]>({
    url: Api.GET_PUBLIC_INTERFACE_ALL
  })
}