import request from '@/utils/request';
import type { ApiResponse, PageData } from '../types';
import type { AgencyDistributionData, AgencyDistributionItem, AgencyQueryParams } from './types';

// 获取中介机构分布数据
export const getAgencyDistribution = (params?: AgencyQueryParams) => {
  return request<ApiResponse<AgencyDistributionData>>({
    url: '/system/dashboard/agency-distribution',
    method: 'get',
    params
  });
};

// 获取机构详细信息
export const getAgencyDetails = (agencyId: string) => {
  return request<ApiResponse<AgencyDistributionItem>>({
    url: `/system/dashboard/agency-distribution/details/${agencyId}`,
    method: 'get'
  });
};

// 获取区域机构列表
export const getAgenciesByRegion = (region: string, params?: { pageNum?: number; pageSize?: number }) => {
  return request<ApiResponse<PageData<AgencyDistributionItem>>>({
    url: `/system/dashboard/agency-distribution/region/${region}`,
    method: 'get',
    params
  });
};
