/** 登录接口 POST /api/login/account */
import { request } from 'umi';

export async function getMapList(body: any, options?: { [key: string]: any }) {
  return request<API.MapInfoRes>('/api/map/queryMapInfo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
    data: body,
  });
}
export async function getBuildingList(body: any, options?: { [key: string]: any }) {
  //debugger;
  return request<API.BuildFloorList>('/api2/object/building/query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
    data: body,
  });
}
export async function getFloorList(body: any, options?: { [key: string]: any }) {
  // debugger;
  return request<API.BuildFloorList>('/api2/object/floor/query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
    data: body,
  });
}
export async function queryDeviceTimeManage(params: any, options?: { [key: string]: any }) {
  //  '/api3/duoduo-service/setup-service/deviceManage/queryDeviceTimeManage'
  return request<API.DeviceTimeType>(
    '/api4/duoduo-service/setup-service/deviceManage/queryDeviceTimeManage',
    {
      method: 'GET',
      params: {
        ...params,
      },
      ...(options || {}),
    },
  );
}

function commonParams() {
  return `openid=9a1ecfbacb6b4f249bf2dd3ec7793ead&pubname=sagacareAndtenantslink&projectId=Pj1101080259&userName=%E5%AE%89%E5%B0%8F%E9%9C%9E&userPhone=17611228068&userId=9a1ecfbacb6b4f249bf2dd3ec7793ead`;
}
// chart
export async function queryPropertyData(params: any, options?: { [key: string]: any }) {
  return request<API.DeviceTimeType>(`/server/spaceAdjust/queryPropertyData?${commonParams()}`, {
    method: 'GET',
    params: params,
    ...(options || {}),
  });
}
export async function queryEnvironmentParam(body: any, otherParam: { [key: string]: any }) {
  //api2/duoduo-service/object-service/object/floor/queryParam
  return request<API.EnvironmentParam>(
    `/api2/object/floor/queryParam?endTime=${otherParam.endTime}&startTime=${otherParam.startTime}&param=${otherParam.param}`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
    },
  );
}

export async function queryEquipStatistics(params: any, options?: { [key: string]: any }) {
  //
  return request<API.EnvironmentParam>(`/api2/object/equipment/queryEquipStatistics`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
    params: {
      ...params,
    },
  });
}

export async function querySpace(body: any, options?: { [key: string]: any }) {
  //
  return request<API.EnvironmentParam>(`/api2/object/space/query`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    ...(options || {}),
    data: body,
  });
}
