diff --git a/apps/common/features/src/entities/attachment/api/attachment-service.ts b/apps/common/features/src/entities/attachment/api/attachment-service.ts index 406cca549..a5352c712 100644 --- a/apps/common/features/src/entities/attachment/api/attachment-service.ts +++ b/apps/common/features/src/entities/attachment/api/attachment-service.ts @@ -26,7 +26,7 @@ export class AttachmentApiService implements AttachmentService { return response.data; } - public async deleteAttachment(atflId: string): Promise { + public async deleteAttachmentByAtflId(atflId: string): Promise { await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); } @@ -36,17 +36,13 @@ export class AttachmentApiService implements AttachmentService { ); } - public async getImageUrl(atflId: string): Promise { + public async getImageUrlByAtflId(atflId: string): Promise { if (!atflId) return ""; const response = await fetch(`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${atflId}`); const blob = await response.blob(); return URL.createObjectURL(blob); } - public async deleteAttachmentByAtflId(atflId: string): Promise { - await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); - } - public async getImageUrlByAtflCd(atflCd: string): Promise { if (!atflCd) return ""; const response = await fetch( @@ -56,6 +52,14 @@ export class AttachmentApiService implements AttachmentService { return URL.createObjectURL(blob); } + public async getMovieThumbnailUrl(atflId: string): Promise { + const response = await fetch( + `${ENDPOINT.ATTACH_SERVICE.MOVIE_THUMBNAIL}/${atflId}`, + ); + const blob = await response.blob(); + return URL.createObjectURL(blob); + } + public async downloadAttachmentByAtflCd( atflCd: string, ): Promise { diff --git a/apps/common/features/src/entities/attachment/model/attachment-interface.ts b/apps/common/features/src/entities/attachment/model/attachment-interface.ts index 00340e9ae..5ad0fc3ea 100644 --- a/apps/common/features/src/entities/attachment/model/attachment-interface.ts +++ b/apps/common/features/src/entities/attachment/model/attachment-interface.ts @@ -36,10 +36,10 @@ export type AttachmentList = PageableList; export interface AttachmentService { getAttachmentsList: (params: AttachmentParams) => Promise; getAttachmentsInfo: (atflCd: string) => Promise; - deleteAttachment: (atflId: string) => Promise; deleteAttachmentByAtflId: (atflId: string) => Promise; deleteAttachmentByAtflCd: (atflCd: string) => Promise; - getImageUrl: (atflId: string) => Promise; + getImageUrlByAtflId: (atflId: string) => Promise; getImageUrlByAtflCd: (atflCd: string) => Promise; + getMovieThumbnailUrl: (atflId: string) => Promise; downloadAttachmentByAtflCd: (atflCd: string) => Promise; } diff --git a/apps/common/features/src/shared/config/api.ts b/apps/common/features/src/shared/config/api.ts index 69bd31b2c..243afca6d 100644 --- a/apps/common/features/src/shared/config/api.ts +++ b/apps/common/features/src/shared/config/api.ts @@ -7,6 +7,7 @@ export const ENDPOINT = { 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", }, diff --git a/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx b/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx index a0a133ed0..242c7ee2f 100644 --- a/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx +++ b/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx @@ -48,22 +48,17 @@ export const createColumns = ( { id: "atflCd", cell: ({ row }) => { - const atflCd = row.original.atflCd; - return ( - - ); + const { atflCd, pstNo } = row.original; + return ; }, }, { id: "rgtrNm", cell: ({ row }) => { - const { rgtrNm } = row.original; return ( - {rgtrNm} + + {row.original.rgtrNm} + ); }, }, diff --git a/apps/common/features/src/widgets/post/ui/with-preview-file-uploader.tsx b/apps/common/features/src/widgets/post/ui/with-preview-file-uploader.tsx index 7dc8bee90..618108017 100644 --- a/apps/common/features/src/widgets/post/ui/with-preview-file-uploader.tsx +++ b/apps/common/features/src/widgets/post/ui/with-preview-file-uploader.tsx @@ -7,6 +7,7 @@ import { handleTusUpload } from "@/entities/tus"; import { AttachmentApi, type Attachment } from "@/entities/attachment"; import type { PostFormData, PostUpdateFormData } from "@/entities/post"; import { setCookie, useAlertStore, useMenuStore } from "@/shared/lib"; +import type { BbsType } from "@/shared/store/menu-store"; function WithPreviewFileUploader({ form, @@ -21,6 +22,17 @@ function WithPreviewFileUploader({ const [thumbnailUrl, setThumbnailUrl] = useState(""); const [progress, setProgress] = useState(0); + const fileAccept = (bbsTypeCd: BbsType) => { + switch (bbsTypeCd) { + case "BBSIMAGE": + return ".jpeg,.jpg,.png"; + case "BBSMOVIE": + return ".mp4,.mov,.avi,.wmv,.mkv"; + default: + return ""; + } + }; + const handleTusResponse = async (res: HttpResponse) => { const fileInfo = res.getHeader("X-File-Info"); if ( @@ -33,7 +45,13 @@ function WithPreviewFileUploader({ const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; if (atflCd) form.setValue("atflCd" as FieldPath, atflCd); if (atflId) { - const imageUrl = await AttachmentApi.getImageUrl(atflId); + let imageUrl = ""; + if (bbsInfo?.bbsTypeCd === "BBSIMAGE") { + imageUrl = await AttachmentApi.getImageUrlByAtflId(atflId); + } + if (bbsInfo?.bbsTypeCd === "BBSMOVIE") { + imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId); + } setThumbnailUrl(imageUrl); } }; @@ -67,7 +85,7 @@ function WithPreviewFileUploader({ useEffect(() => { if (!attachmentData || attachmentData.length === 0) return; (async () => { - const imageUrl = await AttachmentApi.getImageUrl( + const imageUrl = await AttachmentApi.getImageUrlByAtflId( attachmentData[0]?.atflId as string, ); setThumbnailUrl(imageUrl); @@ -77,8 +95,8 @@ function WithPreviewFileUploader({ return ( diff --git a/apps/cs/src/entities/attachment/api/attachment-service.ts b/apps/cs/src/entities/attachment/api/attachment-service.ts index 1565d354e..a5352c712 100644 --- a/apps/cs/src/entities/attachment/api/attachment-service.ts +++ b/apps/cs/src/entities/attachment/api/attachment-service.ts @@ -26,10 +26,6 @@ export class AttachmentApiService implements AttachmentService { return response.data; } - public async deleteAttachment(atflId: string): Promise { - await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); - } - public async deleteAttachmentByAtflId(atflId: string): Promise { await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); } @@ -40,7 +36,7 @@ export class AttachmentApiService implements AttachmentService { ); } - public async getImageUrl(atflId: string): Promise { + public async getImageUrlByAtflId(atflId: string): Promise { if (!atflId) return ""; const response = await fetch(`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${atflId}`); const blob = await response.blob(); diff --git a/apps/cs/src/entities/attachment/model/attachment-interface.ts b/apps/cs/src/entities/attachment/model/attachment-interface.ts index 71b42f1c7..5ad0fc3ea 100644 --- a/apps/cs/src/entities/attachment/model/attachment-interface.ts +++ b/apps/cs/src/entities/attachment/model/attachment-interface.ts @@ -36,10 +36,9 @@ export type AttachmentList = PageableList; export interface AttachmentService { getAttachmentsList: (params: AttachmentParams) => Promise; getAttachmentsInfo: (atflCd: string) => Promise; - deleteAttachment: (atflId: string) => Promise; deleteAttachmentByAtflId: (atflId: string) => Promise; deleteAttachmentByAtflCd: (atflCd: string) => Promise; - getImageUrl: (atflId: string) => Promise; + getImageUrlByAtflId: (atflId: string) => Promise; getImageUrlByAtflCd: (atflCd: string) => Promise; getMovieThumbnailUrl: (atflId: string) => Promise; downloadAttachmentByAtflCd: (atflCd: string) => Promise; diff --git a/apps/cs/src/pages/banner/ui/banner-form.tsx b/apps/cs/src/pages/banner/ui/banner-form.tsx index f99742ba5..7dd4a0a83 100644 --- a/apps/cs/src/pages/banner/ui/banner-form.tsx +++ b/apps/cs/src/pages/banner/ui/banner-form.tsx @@ -59,7 +59,7 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) { const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; if (atflCd) form.setValue("atflCd", atflCd); - if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId)); + if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId)); if (attachmentData) await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd); }; @@ -68,7 +68,9 @@ function BannerForm({ form, bnrSn, ...props }: BannerFormProps) { if (!attachmentData) return; (async () => { - setImageUrl(await AttachmentApi.getImageUrl(attachmentData.atflId)); + setImageUrl( + await AttachmentApi.getImageUrlByAtflId(attachmentData.atflId), + ); })(); }, [attachmentData]); diff --git a/apps/cs/src/pages/file/ui/file-page.tsx b/apps/cs/src/pages/file/ui/file-page.tsx index 4f6b79781..cb80e00b0 100644 --- a/apps/cs/src/pages/file/ui/file-page.tsx +++ b/apps/cs/src/pages/file/ui/file-page.tsx @@ -39,7 +39,8 @@ function FilePage() { }); const { mutate: deleteAttachment } = useMutation({ - mutationFn: (atflId: string) => AttachmentApi.deleteAttachment(atflId), + mutationFn: (atflId: string) => + AttachmentApi.deleteAttachmentByAtflId(atflId), onSuccess: () => { refetch(); alert("삭제되었습니다."); diff --git a/apps/cs/src/pages/image/ui/image-form.tsx b/apps/cs/src/pages/image/ui/image-form.tsx index 979ff931d..7018e6919 100644 --- a/apps/cs/src/pages/image/ui/image-form.tsx +++ b/apps/cs/src/pages/image/ui/image-form.tsx @@ -60,7 +60,7 @@ function ImageForm({ form, imgSn, ...props }: ImageFormProps) { const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; if (atflCd) form.setValue("atflCd", atflCd); - if (atflId) setImageUrl(await AttachmentApi.getImageUrl(atflId)); + if (atflId) setImageUrl(await AttachmentApi.getImageUrlByAtflId(atflId)); if (attachmentData) await AttachmentApi.deleteAttachmentByAtflCd(attachmentData.atflCd); }; diff --git a/apps/cs/src/widgets/post/model/grid-view-table-columns.tsx b/apps/cs/src/widgets/post/model/grid-view-table-columns.tsx index a0a133ed0..242c7ee2f 100644 --- a/apps/cs/src/widgets/post/model/grid-view-table-columns.tsx +++ b/apps/cs/src/widgets/post/model/grid-view-table-columns.tsx @@ -48,22 +48,17 @@ export const createColumns = ( { id: "atflCd", cell: ({ row }) => { - const atflCd = row.original.atflCd; - return ( - - ); + const { atflCd, pstNo } = row.original; + return ; }, }, { id: "rgtrNm", cell: ({ row }) => { - const { rgtrNm } = row.original; return ( - {rgtrNm} + + {row.original.rgtrNm} + ); }, }, diff --git a/apps/cs/src/widgets/post/ui/with-preview-file-uploader.tsx b/apps/cs/src/widgets/post/ui/with-preview-file-uploader.tsx index 129f2b3c2..618108017 100644 --- a/apps/cs/src/widgets/post/ui/with-preview-file-uploader.tsx +++ b/apps/cs/src/widgets/post/ui/with-preview-file-uploader.tsx @@ -47,7 +47,7 @@ function WithPreviewFileUploader({ if (atflId) { let imageUrl = ""; if (bbsInfo?.bbsTypeCd === "BBSIMAGE") { - imageUrl = await AttachmentApi.getImageUrl(atflId); + imageUrl = await AttachmentApi.getImageUrlByAtflId(atflId); } if (bbsInfo?.bbsTypeCd === "BBSMOVIE") { imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId); @@ -85,7 +85,7 @@ function WithPreviewFileUploader({ useEffect(() => { if (!attachmentData || attachmentData.length === 0) return; (async () => { - const imageUrl = await AttachmentApi.getImageUrl( + const imageUrl = await AttachmentApi.getImageUrlByAtflId( attachmentData[0]?.atflId as string, ); setThumbnailUrl(imageUrl); @@ -95,7 +95,7 @@ function WithPreviewFileUploader({ return (