import { request } from '@umijs/max';
import { RespResultList } from './Resp';

const IS_PROD = process.env.NODE_ENV === 'production' ? true : false;
const reqBaseUrl = IS_PROD ? '/cd-comprehensive/apis/physicalsignindex' : '/apis/physicalsignindex';

const urlProxyApis = (url: string) => {
  return `${reqBaseUrl}${url}`;
};
/**
 * 获取区域指数列表
 * @returns
 */
export function getDistrictIndexList(params?: {
  /** 1实况指数  3周期指数 */
  physicalSignType?: number;
  /** 指数体系类型 0:内评价 1:外评价 */
  indexType?: number;
  /** 指数id */
  indexId?: number;
  /** 网格id */
  objectId?: number;
  /** 指数层级，从1开始，多个用,逗号隔开 */
  indexHierarchy?: number;
  /** 对象层级，从1开始，多个用,逗号隔开 */
  objectHierarchy?: number;
}) {
  return request<RespResultList<DistrictAPI.RealtimeIndexDTO>>(
    urlProxyApis('/main/getDistrictIndexInstanceRanking'),
    {
      method: 'GET',
      params: {
        physicalSignType: 1,
        indexType: 1,
        indexId: 1,
        objectId: '',
        sort: 'asc',
        indexHierarchy: '',
        objectHierarchy: 1,
        ...params,
      },
    },
  );
}

// 区市县运行情况 cqi排名
export const getListIndexInstance = (
  params: any,
): Promise<any> => {
  return request(urlProxyApis(`/main/listIndexInstance`), {
    params,
    method: 'GET',
  });
};
