feat: 메인화면 UI 수정, 공지 카테고리 설정, 아카이브 기능 추가
All checks were successful
Deploy blog-frontend / build-and-deploy (push) Successful in 1m47s
All checks were successful
Deploy blog-frontend / build-and-deploy (push) Successful in 1m47s
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { http } from './http';
|
||||
import { ApiResponse, PostListResponse, Post } from '@/types';
|
||||
|
||||
// 1. 게시글 목록 조회 (검색, 카테고리, 태그 필터링 지원)
|
||||
// 1. 게시글 목록 조회 (검색, 카테고리, 태그, 정렬 필터링 지원)
|
||||
export const getPosts = async (params?: {
|
||||
page?: number;
|
||||
size?: number;
|
||||
keyword?: string;
|
||||
category?: string;
|
||||
tag?: string;
|
||||
sort?: string; // 🆕 정렬 옵션 추가 (예: 'viewCount,desc')
|
||||
}) => {
|
||||
const response = await http.get<ApiResponse<PostListResponse>>('/api/posts', {
|
||||
params: {
|
||||
...params,
|
||||
sort: 'createdAt,desc',
|
||||
// 정렬 값이 없으면 기본값(최신순) 적용
|
||||
sort: params?.sort || 'createdAt,desc',
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
@@ -33,20 +35,19 @@ export const getPost = async (slug: string) => {
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 4. 게시글 작성 (추가됨)
|
||||
// PostSaveRequest 타입에 맞춰 데이터를 보냅니다.
|
||||
// 4. 게시글 작성
|
||||
export const createPost = async (data: any) => {
|
||||
const response = await http.post<ApiResponse<Post>>('/api/admin/posts', data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// 5. 게시글 수정 (추가됨)
|
||||
// 5. 게시글 수정
|
||||
export const updatePost = async (id: number, data: any) => {
|
||||
const response = await http.put<ApiResponse<Post>>(`/api/admin/posts/${id}`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// 6. 게시글 삭제 (추가됨)
|
||||
// 6. 게시글 삭제
|
||||
export const deletePost = async (id: number) => {
|
||||
const response = await http.delete<ApiResponse<null>>(`/api/admin/posts/${id}`);
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user