Spaces:
Sleeping
Sleeping
| import { | |
| Controller, | |
| Get, | |
| Put, | |
| Patch, | |
| Body, | |
| Param, | |
| ParseIntPipe, | |
| UseGuards, | |
| Request, | |
| } from '@nestjs/common'; | |
| import { | |
| ApiTags, | |
| ApiOperation, | |
| ApiResponse, | |
| ApiBearerAuth, | |
| ApiParam, | |
| } from '@nestjs/swagger'; | |
| import { JwtAuthGuard } from './guards/jwt-auth.guard'; | |
| import { UserManagementService } from './user-management.service'; | |
| import { | |
| UpdateProfileDto, | |
| UpdateUserPreferencesDto, | |
| ChangePasswordDto, | |
| } from './dto/user-management.dto'; | |
| ('User Profile') | |
| ('JWT-auth') | |
| ('api/users') | |
| (JwtAuthGuard) | |
| export class UserProfileController { | |
| constructor(private readonly userManagementService: UserManagementService) {} | |
| ('profile') | |
| ({ summary: 'Get current user profile' }) | |
| ({ | |
| status: 200, | |
| description: 'User profile with completeness score', | |
| }) | |
| async getProfile(() req) { | |
| return this.userManagementService.getProfile(req.user.userId); | |
| } | |
| ('profile') | |
| ({ summary: 'Update current user profile' }) | |
| ({ status: 200, description: 'Updated profile' }) | |
| async updateProfile(() req, () dto: UpdateProfileDto) { | |
| return this.userManagementService.updateProfile(req.user.userId, dto); | |
| } | |
| ('preferences') | |
| ({ summary: 'Get user preferences' }) | |
| ({ status: 200, description: 'User preferences' }) | |
| async getPreferences(() req) { | |
| return this.userManagementService.getPreferences(req.user.userId); | |
| } | |
| (':id/public') | |
| ({ summary: 'Get public profile for a user' }) | |
| ({ name: 'id', type: Number, description: 'User ID' }) | |
| ({ | |
| status: 200, | |
| description: | |
| 'Public profile returned with non-sensitive contact details (email and social links)', | |
| }) | |
| ({ status: 404, description: 'User not found' }) | |
| async getPublicProfile(('id', ParseIntPipe) userId: number) { | |
| return this.userManagementService.getPublicProfile(userId); | |
| } | |
| ('preferences') | |
| ({ summary: 'Update user preferences' }) | |
| ({ status: 200, description: 'Updated preferences' }) | |
| async updatePreferences( | |
| () req, | |
| () dto: UpdateUserPreferencesDto, | |
| ) { | |
| return this.userManagementService.updatePreferences(req.user.userId, dto); | |
| } | |
| ('password') | |
| ({ summary: 'Change password' }) | |
| ({ status: 200, description: 'Password changed successfully' }) | |
| ({ status: 400, description: 'Current password is incorrect' }) | |
| async changePassword(() req, () dto: ChangePasswordDto) { | |
| return this.userManagementService.changePassword(req.user.userId, dto); | |
| } | |
| } | |