import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MessagesVO, MessagesForm, MessagesQuery } from '@/api/system/business/messages/types';

/**
 * 查询消息主列表
 * @param query
 * @returns {*}
 */

export const listMessages = (query?: MessagesQuery): AxiosPromise<MessagesVO[]> => {
  return request({
    url: '/business/messages/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询消息主详细
 * @param id
 */
export const getMessages = (id: string | number): AxiosPromise<MessagesVO> => {
  return request({
    url: '/business/messages/' + id,
    method: 'get'
  });
};

/**
 * 新增消息主
 * @param data
 */
export const addMessages = (data: MessagesForm) => {
  return request({
    url: '/business/messages',
    method: 'post',
    data: data
  });
};

/**
 * 修改消息主
 * @param data
 */
export const updateMessages = (data: MessagesForm) => {
  return request({
    url: '/business/messages',
    method: 'put',
    data: data
  });
};

/**
 * 删除消息主
 * @param id
 */
export const delMessages = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/messages/' + id,
    method: 'delete'
  });
};
