/**
 * @description: 车辆信息管理
 */
import { http } from '@/utils/http/axios';
import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';

/**
 * @description: 分页查询车辆信息列表
 */
export interface VehicleListQuery {
  fieldType?: string;
  fieldContent?: string;
}
export interface VehicleInfoStruct {
  id?: number; // 自增主键
  carNum?: string; // 车牌号
  userId?: number; // 用户id
  userName?: string; // 用户姓名
  staffNo?: string; // 工号
  deptId?: number; // 部门id
  deptName?: string; // 部门名称
  phoneNum?: string; // 联系方式
  createdAt?: string; // 创建时间
  updatedAt?: string; // 更新时间
  isDeleted?: number; // 0-未删除，大于0(时间戳)-已删除
}
export const getVehicleInfoList = (params: QueryPageRequest<VehicleListQuery>) => {
  return http.request<QueryPageResponse<VehicleInfoStruct>>({
    url: '/vehicleInfo/queryVehicleInfoPage',
    method: 'post',
    params,
  });
};

/**
 * @description: 添加车辆信息
 */
export const addVehicleInfo = (params: VehicleInfoStruct) => {
  return http.request({
    url: '/vehicleInfo/saveVehicleInfo',
    method: 'post',
    params,
  });
};

/**
 * @description: 更新车辆信息
 */
export const updateVehicleInfo = (params: VehicleInfoStruct) => {
  return http.request({
    url: '/vehicleInfo/updateVehicleInfo',
    method: 'put',
    params,
  });
};

/**
 * @description: 删除车辆信息（单个/批量）
 */
export const deleteVehicleInfo = (params: { vehicleInfoIds: number[] }) => {
  return http.request({
    url: '/vehicleInfo/deleteVehicleInfo',
    method: 'delete',
    params,
  });
};

/**
 * @description: 导出车辆信息
 */
export function exportVehicleInfo(params: VehicleListQuery) {
  return http.request(
    {
      url: '/vehicleInfo/exportVehicleInfo',
      method: 'post',
      responseType: 'blob',
      params,
    },
    { isTransformResponse: false },
  );
}
