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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,15 @@ export class ContentsRepository {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<typeof contents.$inferInsert>) {
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user