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

/** VIP 功能字典 API */
const prefix = 'vip-feature/';

export async function getVipFeatureList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

export async function getVipFeatureOption(data?: any) {
  return requestClient.get<any>(`${prefix}option`, { params: data });
}

export async function createVipFeature(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

export async function updateVipFeature(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

export async function deleteVipFeature(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}

/**
 * 功能反绑会员等级
 * @param data.id 功能 id
 * @param data.code 功能编码（可选，有 id 即可）
 * @param data.level_ids 勾选的等级 id 列表
 */
export async function bindVipFeatureLevels(data: {
  id: number;
  code?: string;
  level_ids: number[];
}) {
  return requestClient.post<any>(`${prefix}bind-levels`, data);
}
