Skip to content

Commit

Permalink
#267 feat: 공지사항 api 타입 선언
Browse files Browse the repository at this point in the history
  • Loading branch information
pillow12360 committed Jan 13, 2025
1 parent 098bd14 commit 80486ee
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions frontend/src/types/api/notice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ApiResponse, PaginationParams } from './common';

export interface NoticeItem {
id: number;
title: string;
content: string;
writer: string;
viewCount: number;
createdDate: string;
category: string;
fileList?: string[];
}

export interface NoticeResponse {
message: string;
page: number;
totalPage: number;
data: NoticeItem[];
}

export interface NoticeRequest {
title: string;
content: string;
writer: string;
category: string;
departmentId: number;
fileList?: string[];
createDate: string;
}

export interface NoticeFormData extends Omit<NoticeRequest, 'fileList'> {
files?: File[];
}

export interface PaginatedNoticeResponse {
content: NoticeItem[];
totalPages: number;
totalElements: number;
size: number;
number: number;
}

export type NoticeListResponse = ApiResponse<NoticeResponse>;
export type NoticeSingleResponse = ApiResponse<NoticeItem>;
export type NoticeCreateResponse = ApiResponse<number>;
export type NoticeUpdateResponse = ApiResponse<void>;
export type NoticeDeleteResponse = ApiResponse<void>;

export interface NoticeQueryParams extends PaginationParams {
category?: string;
sort?: string;
sortDirection?: 'ASC' | 'DESC';
}

// Query Keys
export const noticeKeys = {
all: ['notices'] as const,
lists: () => [...noticeKeys.all, 'list'] as const,
list: (params: NoticeQueryParams) => [...noticeKeys.lists(), params] as const,
details: () => [...noticeKeys.all, 'detail'] as const,
detail: (id: number) => [...noticeKeys.details(), id] as const,
};

0 comments on commit 80486ee

Please sign in to comment.