import request from '@/utils/request'
import type { 
  AdminPageRequest, 
  AdminCreateRequest, 
  AdminUpdateRequest,
  Admin
} from '@/types/admin'
import type { ApiResponse, PageResult } from '@/types/common'

// 分页查询管理员
export function getAdminPage(params: AdminPageRequest) {
  return request<ApiResponse<PageResult<Admin>>>({
    url: '/admin/page',
    method: 'get',
    params
  })
}

// 根据ID获取管理员
export function getAdminById(id: string) {
  return request<ApiResponse<Admin>>({
    url: '/admin/detail',
    method: 'get',
    params: { id }
  })
}

// 创建管理员
export function createAdmin(data: AdminCreateRequest) {
  return request<ApiResponse<Admin>>({
    url: '/admin/create',
    method: 'post',
    data
  })
}

// 更新管理员
export function updateAdmin(data: AdminUpdateRequest) {
  return request<ApiResponse<Admin>>({
    url: '/admin/update',
    method: 'put',
    data
  })
}

// 删除管理员
export function deleteAdmin(id: string) {
  return request<ApiResponse<void>>({
    url: '/admin/delete',
    method: 'delete',
    params: { id }
  })
}
