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

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

// 岗位 VO 类型
export interface WorkstationVO {
  id?: number;
  workstationId?: number;
  workstationCode: string;
  workstationName: string;
  parentId?: number;
  enableFlag?: string;
  remark?: string;
  createBy?: string;
  createTime?: Date | string;
  updateBy?: string;
  updateTime?: Date | string;
  children?: WorkstationVO[];
}

// 岗位管理 API
export const workstationApi = {
  // 查询岗位列表
  listMarsDept: (params: PageParam): Promise<{ list: WorkstationVO[] }> => {
    return axiosInstance.get('/iscs/workstation/getWorkstationPage', { params });
  },

  // 查询岗位详细
  getMarsDept: (id: number): Promise<WorkstationVO> => {
    return axiosInstance.get('/iscs/workstation/selectWorkstationById', {
      params: { id }
    });
  },

  // 新增岗位
  addMarsDept: (data: WorkstationVO): Promise<void> => {
    return axiosInstance.post('/iscs/workstation/insertWorkstation', data);
  },

  // 修改岗位
  updateMarsDept: (data: WorkstationVO): Promise<void> => {
    return axiosInstance.put('/iscs/workstation/updateWorkstation', data);
  },

  // 删除岗位
  delMarsDept: (ids: string): Promise<void> => {
    return axiosInstance.delete(`/iscs/workstation/deleteWorkstationList?ids=${ids}`);
  },
};

