Files
admin/dashboard/frontend/src/service/api/www-news.ts
T
2026-07-30 18:27:42 +08:00

33 lines
1.3 KiB
TypeScript

import { request } from '../request';
import type { PageParams } from './brand';
// ===== 新闻文章 =====
export function fetchGetNews(params?: PageParams & { status?: string; title?: string }) {
return request<Api.Common.PageResult<Api.Www.NewsArticle>>({ url: '/www/news', method: 'get', params });
}
export function fetchGetNewsArticle(id: number) {
return request<Api.Www.NewsArticle>({ url: `/www/news/${id}`, method: 'get' });
}
export function fetchCreateNewsArticle(data: Api.Www.NewsArticlePayload) {
return request<Api.Www.NewsArticle>({ url: '/www/news', method: 'post', data });
}
export function fetchUpdateNewsArticle(id: number, data: Partial<Api.Www.NewsArticlePayload>) {
return request<Api.Www.NewsArticle>({ url: `/www/news/${id}`, method: 'put', data });
}
export function fetchDeleteNewsArticle(id: number) {
return request({ url: `/www/news/${id}`, method: 'delete' });
}
// ===== 文章推荐 =====
export function fetchGetNewsRecommendations(id: number) {
return request<Api.Www.NewsArticle[]>({ url: `/www/news/${id}/recommendations`, method: 'get' });
}
export function fetchUpdateNewsRecommendations(id: number, recommendedIds: number[]) {
return request({ url: `/www/news/${id}/recommendations`, method: 'put', data: { recommended_ids: recommendedIds } });
}