import { requestClient } from '#/api/request';

/**
 * 员工 OA 账号管理 API
 * 路由前缀：admin-oa-account/
 */
const prefix = 'admin-oa-account/';

/**
 * 获取指定员工的所有 OA 账号（按平台分组）
 * 返回结构：['work_wechat' => [{id, account_id, account_name}, ...], ...]
 */
export async function getAdminOaAccounts(adminId: number) {
  return requestClient.get<any>(`${prefix}list`, { params: { admin_id: adminId } });
}

/**
 * 保存员工的 OA 账号配置（全量同步）
 * accounts 结构：{ platform_code: [{account_id, account_name}, ...] }
 */
export async function saveAdminOaAccounts(adminId: number, accounts: Record<string, any[]>) {
  return requestClient.post<any>(`${prefix}save`, { admin_id: adminId, accounts });
}
