feat: stabilize social backend contracts
هذا الالتزام موجود في:
58
src/modules/follows/follows-users.controller.ts
Normal file
58
src/modules/follows/follows-users.controller.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { Controller, Delete, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
||||
import { PaginationQueryDto } from '../../common/dto/pagination-query.dto';
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||
import { JwtPayload } from '../../common/interfaces/jwt-payload.interface';
|
||||
import { FollowsService } from './follows.service';
|
||||
|
||||
@ApiTags('Users')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('users')
|
||||
export class FollowsUsersController {
|
||||
constructor(private readonly followsService: FollowsService) {}
|
||||
|
||||
@Get('me/followers')
|
||||
async myFollowers(@CurrentUser() user: JwtPayload, @Query() query: PaginationQueryDto) {
|
||||
return this.followsService.getFollowers(user.sub, query, user.sub);
|
||||
}
|
||||
|
||||
@Get('me/following')
|
||||
async myFollowing(@CurrentUser() user: JwtPayload, @Query() query: PaginationQueryDto) {
|
||||
return this.followsService.getFollowing(user.sub, query, user.sub);
|
||||
}
|
||||
|
||||
@Post(':userId/follow')
|
||||
async followUser(@CurrentUser() user: JwtPayload, @Param('userId') targetUserId: string) {
|
||||
return this.followsService.followUser(user.sub, targetUserId);
|
||||
}
|
||||
|
||||
@Delete(':userId/follow')
|
||||
async unfollowUser(@CurrentUser() user: JwtPayload, @Param('userId') targetUserId: string) {
|
||||
return this.followsService.unfollowUser(user.sub, targetUserId);
|
||||
}
|
||||
|
||||
@Get(':userId/follow-status')
|
||||
async followStatus(@CurrentUser() user: JwtPayload, @Param('userId') targetUserId: string) {
|
||||
return this.followsService.getFollowStatus(user.sub, targetUserId);
|
||||
}
|
||||
|
||||
@Get(':userId/followers')
|
||||
async followers(
|
||||
@CurrentUser() user: JwtPayload,
|
||||
@Param('userId') targetUserId: string,
|
||||
@Query() query: PaginationQueryDto,
|
||||
) {
|
||||
return this.followsService.getFollowers(targetUserId, query, user.sub);
|
||||
}
|
||||
|
||||
@Get(':userId/following')
|
||||
async following(
|
||||
@CurrentUser() user: JwtPayload,
|
||||
@Param('userId') targetUserId: string,
|
||||
@Query() query: PaginationQueryDto,
|
||||
) {
|
||||
return this.followsService.getFollowing(targetUserId, query, user.sub);
|
||||
}
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم