import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PageVO, PageForm, PageQuery } from '@/api/system/page/types';

/**
 * 查询页面列表
 * @param query
 * @returns {*}
 */

export const listPage = (query?: PageQuery): AxiosPromise<PageVO[]> => {
  return request({
    url: '/system/page/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询页面详细
 * @param id
 */
export const getPage = (id: string | number): AxiosPromise<PageVO> => {
  return request({
    url: '/system/page/' + id,
    method: 'get'
  });
};

/**
 * 新增页面
 * @param data
 */
export const addPage = (data: PageForm) => {
  return request({
    url: '/system/page',
    method: 'post',
    data: data
  });
};

/**
 * 修改页面
 * @param data
 */
export const updatePage = (data: PageForm) => {
  return request({
    url: '/system/page',
    method: 'put',
    data: data
  });
};

/**
 * 删除页面
 * @param id
 */
export const delPage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/page/' + id,
    method: 'delete'
  });
};
