59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
/**
|
|
* 📄 Attachment Service
|
|
* 첨부 파일 서비스 클래스
|
|
*
|
|
* - 첨부 파일 목록 조회 및 페이지네이션 지원
|
|
* - 첨부 파일 상세 정보 조회 기능
|
|
* - 첨부 파일 삭제 기능
|
|
* - Axios 기반 HTTP 요청 처리
|
|
* - 타입 안전성 보장을 위한 인터페이스 활용
|
|
* - 첨부 파일 CRUD 작업을 위한 표준화된 서비스 메소드
|
|
*
|
|
* 🔗 사용 API
|
|
* - 첨부 파일 조회: GET /attach-service/api/v1/atfl/attachments (attach-service)
|
|
* - 첨부 파일 삭제: DELETE /attach-service/api/v1/atfl/attachments/atflCd (attach-service)
|
|
*/
|
|
import type { AxiosResponse } from "axios";
|
|
import type {
|
|
Attachment,
|
|
AttachmentList,
|
|
AttachmentParams,
|
|
AttachmentService,
|
|
} from "../attachment/attachment-interface";
|
|
import { getData, deleteData } from "../index";
|
|
|
|
export const ENDPOINT = {
|
|
ATTACH_SERVICE: {
|
|
TUS_UPLOAD: "/attach-service/api/v1/tus/upload",
|
|
EDITOR_UPLOAD: "/attach-service/api/v1/upload/editor",
|
|
IMAGES: "/attach-service/api/v1/images",
|
|
MOVIE_THUMBNAIL: "/attach-service/api/v1/movie/thumbnail",
|
|
ATTACHMENTS: "/attach-service/api/v1/atfl/attachments",
|
|
DOWNLOAD: "/attach-service/api/v1/atflcd/download",
|
|
STREAM_VIDEO: "/attach-service/api/v1/stream/video",
|
|
DELETE_FILE_BY_ATFLCD: "/attach-service/api/v1/atfl/attachments/atflCd",
|
|
},
|
|
};
|
|
|
|
export class AttachmentApiService implements AttachmentService {
|
|
public async getAttachmentsList(
|
|
params: AttachmentParams,
|
|
): Promise<AttachmentList> {
|
|
const response = await getData(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}`);
|
|
return response.data;
|
|
}
|
|
|
|
public async getAttachmentsInfo(atflCd: string): Promise<Attachment[]> {
|
|
const response = await getData(
|
|
`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflCd}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async deleteAttachmentByAtflCd(atflCd: string): Promise<void> {
|
|
await deleteData(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/atflCd/${atflCd}`);
|
|
}
|
|
}
|
|
|
|
export const AttachmentApi = new AttachmentApiService();
|