import { defHttp } from '@/utils/http/axios';
import { ID, IDS, commonExport } from '@/api/base';
import {
  MaintenanceRecordVO,
  MaintenanceRecordForm,
  MaintenancePlanForm,
  MaintenanceRecordQuery,
  MaintenancePlanQuery,
  MaintenancePlanVO,
  AnnualPlanQuery,
  AnnualPlanVO,
} from './model';

/**
 * 查询维保记录;列表
 * @param params
 * @returns
 */
export function maintenanceRecordList(params?: MaintenanceRecordQuery) {
  return defHttp.get<MaintenanceRecordVO[]>({
    url: '/mrecord/maintenanceRecord/list',
    params,
  });
}
/**
 * 查询维保计划;列表
 * @param params
 * @returns
 */
export function maintenancePlanList(params?: MaintenancePlanQuery) {
  return defHttp.get<MaintenancePlanVO[]>({ url: '/maintenancePlan/maintenancePlan/list', params });
}

/**
 * 查询年检计划;列表
 * @param params
 * @returns
 */
export function annualPlanList(params?: AnnualPlanQuery) {
  return defHttp.get<AnnualPlanVO[]>({ url: '/annual/annualPlan/list', params });
}
/**
 * 导出维保记录;列表
 * @param params
 * @returns
 */
export function maintenanceRecordExport(params?: MaintenanceRecordQuery) {
  return commonExport('/mrecord/maintenanceRecord/export', params ?? {});
}

/**
 * 查询维保记录;详细
 * @param id id
 * @returns
 */
export function maintenanceRecordInfo(id: ID) {
  return defHttp.get<MaintenanceRecordVO>({ url: '/mrecord/maintenanceRecord/' + id });
}

/**
 * 新增维保记录;
 * @param data
 * @returns
 */
export function maintenanceRecordAdd(data: MaintenanceRecordForm) {
  return defHttp.postWithMsg<void>({ url: '/mrecord/maintenanceRecord', data });
}
/**
 * 新增维保计划;
 * @param data
 * @returns
 */
export function maintenancePlanAdd(data: MaintenancePlanForm) {
  return defHttp.postWithMsg<void>({ url: '/maintenancePlan/maintenancePlan/create', data });
}
/**
 * 更新维保记录;
 * @param data
 * @returns
 */
export function maintenanceRecordUpdate(data: MaintenanceRecordForm) {
  return defHttp.putWithMsg<void>({ url: '/mrecord/maintenanceRecord', data });
}

/**
 * 删除维保记录;
 * @param id id
 * @returns
 */
export function maintenanceRecordRemove(id: ID | IDS) {
  return defHttp.deleteWithMsg<void>({ url: '/mrecord/maintenanceRecord/' + id });
}

/**
 * 删除维保记录;
 * @param id id
 * @returns
 */
export function infoPlanRemove(id: ID | IDS) {
  return defHttp.deleteWithMsg<void>({ url: '/maintenancePlan/maintenancePlan/' + id });
}
