feat: cho phép người dùng chỉnh sửa thông tin ảnh đã upload

This commit is contained in:
2026-06-20 07:37:01 +07:00
parent 4373ed684a
commit 9da8a9494d
18 changed files with 987 additions and 298 deletions
+48 -2
View File
@@ -501,7 +501,13 @@ let PublicTourController = class PublicTourController {
}
}
},
photos: true,
photos: {
include: {
uploader: {
select: { id: true, name: true }
}
}
},
legs: {
orderBy: { sequence: 'asc' },
include: {
@@ -850,7 +856,13 @@ let TourController = class TourController {
}
}
},
photos: true,
photos: {
include: {
uploader: {
select: { id: true, name: true }
}
}
},
legs: {
orderBy: { sequence: 'asc' },
include: {
@@ -1695,6 +1707,31 @@ let PhotoController = class PhotoController {
await this.prisma.photo.delete({ where: { id } });
return { message: 'Ảnh đã được xóa thành công.' };
}
async updatePhoto(id, body, req) {
const photo = await this.prisma.photo.findUnique({
where: { id }
});
if (!photo) {
throw new common_1.NotFoundException('Không tìm thấy ảnh.');
}
if (photo.uploaderId !== req.user.id && !req.user.isAdmin) {
throw new common_1.ForbiddenException('Bạn không có quyền chỉnh sửa thông tin của bức ảnh này.');
}
const currentMetadata = photo.metadata || {};
const updatedMetadata = {
...currentMetadata,
lat: body.latitude !== undefined ? body.latitude : currentMetadata.lat,
lng: body.longitude !== undefined ? body.longitude : currentMetadata.lng,
title: body.title !== undefined ? body.title : currentMetadata.title,
description: body.description !== undefined ? body.description : currentMetadata.description,
};
return this.prisma.photo.update({
where: { id },
data: {
metadata: updatedMetadata
}
});
}
};
__decorate([
(0, common_1.Post)('upload-anonymous'),
@@ -1714,6 +1751,15 @@ __decorate([
__metadata("design:paramtypes", [String, Object]),
__metadata("design:returntype", Promise)
], PhotoController.prototype, "deletePhoto", null);
__decorate([
(0, common_1.Patch)(':id'),
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
__param(1, (0, common_1.Body)()),
__param(2, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object, Object]),
__metadata("design:returntype", Promise)
], PhotoController.prototype, "updatePhoto", null);
PhotoController = __decorate([
(0, common_1.Controller)('photos'),
(0, exports.Roles)(client_1.ParticipantRole.OWNER, client_1.ParticipantRole.MANAGER, client_1.ParticipantRole.MEMBER, client_1.ParticipantRole.MEMBER_NO_FINANCE),
+1 -1
View File
File diff suppressed because one or more lines are too long