feat(media): implement persistent storage & media SEO fields (altText, title, description, caption) (TASK-2.5, TASK-2.6)

This commit is contained in:
parsa aghaei committed 2026-08-02 09:23:30 +03:30
1 parent 357fb73d5e
commit e2e9615bd8
5 files changed
+152 -8

No files matched your search

+13
View File
@@ -2,6 +2,8 @@ import {
Controller,
Get,
Post,
Put,
Body,
Delete,
Param,
UseGuards,
@@ -45,4 +47,15 @@ export class MediaController {
const data = await this.mediaService.deleteMedia(id);
return { success: true, data };
}
@UseGuards(JwtAuthGuard)
@Put(':id')
@ApiOperation({ summary: 'ویرایش متادیتای سئوی فایل (Alt, Title, Description, Caption)' })
async updateMedia(
@Param('id') id: string,
@Body() body: { altText?: string; title?: string; description?: string; caption?: string },
) {
const data = await this.mediaService.updateMedia(id, body);
return { success: true, data };
}
}
+12
View File
@@ -61,4 +61,16 @@ export class MediaService {
await this.prisma.media.delete({ where: { id } });
return { success: true };
}
async updateMedia(id: string, data: { altText?: string; title?: string; description?: string; caption?: string }) {
return this.prisma.media.update({
where: { id },
data: {
altText: data.altText,
title: data.title,
description: data.description,
caption: data.caption,
},
});
}
}