import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InfoVO, InfoForm, InfoQuery } from '@/api/system/business/info/types';

/**
 * 查询新闻信息列表
 * @param query
 * @returns {*}
 */

export const listInfo = (query?: InfoQuery): AxiosPromise<InfoVO[]> => {
  return request({
    url: '/business/info/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询新闻信息详细
 * @param id
 */
export const getInfo = (id: string | number): AxiosPromise<InfoVO> => {
  return request({
    url: '/business/info/' + id,
    method: 'get'
  });
};

/**
 * 新增新闻信息
 * @param data
 */
export const addInfo = (data: InfoForm) => {
  return request({
    url: '/business/info',
    method: 'post',
    data: data
  });
};

/**
 * 修改新闻信息
 * @param data
 */
export const updateInfo = (data: InfoForm) => {
  return request({
    url: '/business/info',
    method: 'put',
    data: data
  });
};

/**
 * 删除新闻信息
 * @param id
 */
export const delInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/info/' + id,
    method: 'delete'
  });
};

export const publishNews = (data: InfoForm) => {
  return request({
    url: '/business/info/publishNews',
    method: 'put',
    data: data
  });
};
