import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserApprovalQuery, SysUserApprovalListVo, UserApprovalDetailVO, UserBatchApprovalBO } from './types';

/**
 * 查询待审批用户列表
 * @param query 查询参数
 */
export const listPendingUsers = (query: UserApprovalQuery): AxiosPromise<SysUserApprovalListVo[]> => {
  return request({
    url: '/system/user/approval/pending',
    method: 'get',
    params: query
  });
};

/**
 * 批量审批通过用户
 * @param data 批量审批数据
 */
export const batchApproveUsers = (data: UserBatchApprovalBO) => {
  return request({
    url: '/system/user/approval/batchApprove',
    method: 'post',
    data: data
  });
};

/**
 * 获取用户审批详情（包含菜单权限树）
 * @param userId 用户ID
 */
export const getApprovalUserDetail = (userId: number | string): AxiosPromise<UserApprovalDetailVO> => {
  return request({
    url: `/system/user/approval/detail/${userId}`,
    method: 'get'
  });
};

export default {
  listPendingUsers,
  batchApproveUsers,
  getApprovalUserDetail
};
