import axiosInstance from '../../utils/axios';

// 分页参数类型
export interface PageParam {
  pageNo?: number;
  pageSize?: number;
  userId?: number;
  [key: string]: any;
}

// 用户特征值 API（指纹、面部）
export const userCharacteristicApi = {
  // 查询用户特征值（指纹、面部）
  getUserType: (params: PageParam): Promise<any> => {
    return axiosInstance.get('/iscs/user-characteristic/getUserCharacteristicPage', { params });
  },

  // 删除用户指纹、人脸
  deleteUserFaceOrFinger: (ids: number): Promise<void> => {
    return axiosInstance.delete(`/iscs/user-characteristic/deleteUserCharacteristicList?ids=${ids}`);
  },

  // 新增用户人脸（上传图片，仅传 userName、file；userName 的值为列表的 username）
  insertUserFace: (userName: string, file: File): Promise<void> => {
    const formData = new FormData();
    formData.append('file', file);
    formData.append('userName', userName);
    return axiosInstance.post('/iscs/user-characteristic/insertUserFace', formData, {
      headers: { 'Content-Type': 'multipart/form-data' },
    });
  },
};

