import type { List } from '@/model';
import type { EducationModel, EducationQuery } from '@/model/education.model';

import request from '@/request/alova';

// 获取宣教列表
export function educationMethod(page?: number, size?: number, query?: EducationQuery) {
  const params: any = { ...query };
  // 如果传了 page 和 size，就添加分页参数
  if (page !== undefined && size !== undefined) {
    params.pageNum = page;
    params.pageSize = size;
  }
  return request.Post<List<EducationModel>, List<any>>(`/fdhb-pc/psaManage/pagePsa`, query ?? {}, {
    hitSource: /education$/,
    params,
  });
}

// 新增/修改宣教
export function editEducationMethod(data: Partial<EducationModel>) {
  return data.id ? request.Post(`/fdhb-pc/psaManage/updatePsa`, data, { name: 'edit-education' }) : request.Post(`/fdhb-pc/psaManage/addPsa`, data, { name: 'add-education' });
}
// 删除宣教
export function deleteEducationMethod(data: Partial<EducationModel>) {
  return request.Post(`/fdhb-pc/psaManage/deletePsa/${data.id}`, { name: 'delete-education' });
}

//启用-停用健康宣教
export function updateEducationStatusMethod(data: Partial<EducationModel>) {
  return request.Get(`/fdhb-pc/psaManage/updateStatus/${data.id}/${data.status}`, { name: 'update-education-status' });
}

//根据健康宣教ID获取健康宣教详情
export function getEducationDetailMethod(id: string) {
  return request.Post(`/fdhb-pc/psaManage/detail/${id}`, { name: 'get-education-detail' });
}