Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 3x 6x 1x 6x 2x 2x 6x 1x 1x 6x 3x 3x | import {
Body,
Controller,
Delete,
HttpCode,
HttpStatus,
Param,
Post,
Query,
Req,
UseGuards,
Get,
Put,
} from '@nestjs/common';
import { UserService } from './user.service';
import { UserBasicInfoDto, UserDto } from './dto/user.dto';
import { AddSkillDto } from './dto/add-skill.dto';
import { AuthGuard } from '../auth/auth.guard';
import { ApiRequest } from '../auth/types/api-request';
import { UpdateUserDto } from './dto/update-user.dto';
@Controller('users')
@UseGuards(AuthGuard)
export class UserController {
constructor(private readonly userService: UserService) {}
@Get('search')
async searchUsers(@Query('name') name: string): Promise<UserBasicInfoDto[]> {
return this.userService.searchUsers(name);
}
@Get(':id')
async getUserById(@Param('id') id: string): Promise<UserDto> {
return await this.userService.getUserById(id);
}
@Put()
async updateUser(
@Req() req: ApiRequest,
@Body() updateUserDto: UpdateUserDto,
): Promise<{ message: string }> {
const userId = req.user.userId;
return await this.userService.updateUser(userId, updateUserDto);
}
@Delete('skills')
@HttpCode(HttpStatus.OK)
async deleteSkill(
@Query('instrumentId') instrumentId: string,
@Req() req: ApiRequest,
): Promise<{ message: string }> {
const userId = req.user.userId;
return await this.userService.deleteSkill(instrumentId, userId);
}
@Post('skills')
@HttpCode(HttpStatus.OK)
async addSkill(
@Req() req: ApiRequest,
@Body() addSkillDto: AddSkillDto,
): Promise<{ message: string }> {
const userId = req.user.userId;
return await this.userService.addSkill(userId, addSkillDto);
}
}
|