From 07cdb741b3a76de2ac6bea330c0160859a3b1b1e Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Wed, 21 Jan 2026 13:18:41 +0100 Subject: [PATCH] feat(contents): add updateAdmin endpoint and repository method - Introduced `PATCH /:id/admin` endpoint to update admin-specific content. - Added `update` method to `ContentsRepository` for data updates with timestamp. --- backend/src/contents/contents.controller.ts | 8 ++++++++ backend/src/contents/repositories/contents.repository.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/backend/src/contents/contents.controller.ts b/backend/src/contents/contents.controller.ts index 8743f45..5b66270 100644 --- a/backend/src/contents/contents.controller.ts +++ b/backend/src/contents/contents.controller.ts @@ -10,6 +10,7 @@ import { Param, ParseBoolPipe, ParseIntPipe, + Patch, Post, Query, Req, @@ -185,4 +186,11 @@ export class ContentsController { removeAdmin(@Param("id") id: string) { return this.contentsService.removeAdmin(id); } + + @Patch(":id/admin") + @UseGuards(AuthGuard, RolesGuard) + @Roles("admin") + updateAdmin(@Param("id") id: string, @Body() updateContentDto: any) { + return this.contentsService.updateAdmin(id, updateContentDto); + } } diff --git a/backend/src/contents/repositories/contents.repository.ts b/backend/src/contents/repositories/contents.repository.ts index 126b09c..d342112 100644 --- a/backend/src/contents/repositories/contents.repository.ts +++ b/backend/src/contents/repositories/contents.repository.ts @@ -404,6 +404,15 @@ export class ContentsRepository { return deleted; } + async update(id: string, data: Partial) { + const [updated] = await this.databaseService.db + .update(contents) + .set({ ...data, updatedAt: new Date() }) + .where(eq(contents.id, id)) + .returning(); + return updated; + } + async findBySlug(slug: string) { const [result] = await this.databaseService.db .select()