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()