هذا الالتزام موجود في:
2026-04-20 15:12:16 +03:00
التزام 28f7241bcd
172 ملفات معدلة مع 21907 إضافات و0 حذوفات

عرض الملف

@@ -0,0 +1,55 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { JwtPayload } from '../../common/interfaces/jwt-payload.interface';
import { CreatePostDto } from './dto/create-post.dto';
import { PostQueryDto } from './dto/post-query.dto';
import { UpdatePostDto } from './dto/update-post.dto';
import { PostsService } from './posts.service';
@ApiTags('Posts')
@Controller('posts')
export class PostsController {
constructor(private readonly postsService: PostsService) {}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post()
async create(@CurrentUser() user: JwtPayload, @Body() dto: CreatePostDto) {
return this.postsService.create(user.sub, dto);
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('user/:userId')
async findUserPosts(@Param('userId') userId: string, @Query() query: PostQueryDto) {
return this.postsService.findUserPosts(userId, query);
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':postId')
async findById(@Param('postId') postId: string) {
return this.postsService.findById(postId);
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Patch(':postId')
async update(
@CurrentUser() user: JwtPayload,
@Param('postId') postId: string,
@Body() dto: UpdatePostDto,
) {
return this.postsService.update(user.sub, postId, dto);
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Delete(':postId')
async remove(@CurrentUser() user: JwtPayload, @Param('postId') postId: string) {
await this.postsService.remove(user.sub, postId);
return { success: true };
}
}