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

export interface BlacklistQuery {
  pageNo?: number;
  pageSize?: number;
  current?: number;
  size?: number;
  userId?: string;
  userName?: string;
  nickName?: string;
  [key: string]: any;
}

export interface BlacklistVO {
  recordId?: number;
  userId: string;
  userName?: string;
  nickName?: string;
  /** 与旧版 BlacklistForm 提交一致，后端常据此写入业务模块 */
  module?: string;
  [key: string]: any;
}

/** 旧版 insertBlacklist 实际提交为数组项：{ userId, module: '2' }[] */
export type BlacklistInsertPayload = Array<{ userId: string | number; module?: string }>;

export const materialBlacklistApi = {
  listBlacklist: (params: BlacklistQuery) =>
    axiosInstance.get('/iscs/blacklist/getBlacklistPage', { params }),
  getBlacklistInfo: (id: number) =>
    axiosInstance.get('/iscs/blacklist/selectBlacklistById', { params: { id } }),
  addBlacklist: (data: BlacklistVO | BlacklistInsertPayload) =>
    axiosInstance.post('/iscs/blacklist/insertBlacklist', data),
  updateBlacklist: (data: BlacklistVO) => axiosInstance.put('/iscs/blacklist/updateBlacklist', data),
  delBlacklist: (ids: number | string) =>
    axiosInstance.delete('/iscs/blacklist/deleteBlacklistList', { params: { ids } }),
  listWhitelist: (params: BlacklistQuery) =>
    axiosInstance.get('/iscs/blacklist/getWhiteUserPage', { params }),
};
