import request from '@/utils/request';

const baseUrl = '/dgtmedicine/news';

/**
 * 查询新闻列表
 */
export const fetchNewsList = (params: any) => {
    return request.get(`${baseUrl}/list`, { params });
};

/**
 * 获取新闻详细信息
 * @param id 主键
 */
export const getNewsInfo = (id: number) => {
    return request.get(`${baseUrl}/getInfo/${id}`);
};

/**
 * 新增新闻
 */
export const addNews = (data: any) => {
    return request.post(`${baseUrl}/add`, data);
};

/**
 * 修改新闻
 */
export const editNews = (data: any) => {
    return request.post(`${baseUrl}/edit`, data);
};

/**
 * 删除新闻
 * @param ids 主键数组
 */
export const removeNews = (ids: number[]) => {
    return request.get(`${baseUrl}/remove/${ids.join(',')}`);
};

/**
 * 上架新闻
 * @param id 主键
 */
export const publishNews = (id: number) => {
    return request.get(`${baseUrl}/publish/${id}`);
};

/**
 * 下架新闻
 * @param id 主键
 */
export const unpublishNews = (id: number) => {
    return request.get(`${baseUrl}/unpublish/${id}`);
};
