feat(cities): добавляет DTO для создания города и района

 feat(greetings): добавляет схему для тела запроса при добавлении фразы приветствия

 feat(auth): добавляет схему для тела запроса при обновлении FCM токена

 feat(tags): добавляет схему для тела запроса при создании тега
This commit is contained in:
Oscar
2026-06-08 14:29:40 +03:00
parent 102b6b4026
commit 8b852c9f28
5 changed files with 26 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { AuthService } from './auth.service';
import { LoginDto } from './dto/login.dto';
import { RefreshTokenDto } from './dto/refresh-token.dto';
@@ -52,6 +52,7 @@ export class AuthController {
@Post('fcm-token')
@ApiBearerAuth()
@ApiOperation({ summary: 'Update FCM push token' })
@ApiBody({ schema: { type: 'object', properties: { fcmToken: { type: 'string', example: 'firebase-token-abc123' } }, required: ['fcmToken'] } })
@ApiResponse({ status: 201, type: MessageResponseDto })
updateFcmToken(
@CurrentUser('id') userId: string,

View File

@@ -6,6 +6,7 @@ import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { RolesGuard } from '../../common/guards/roles.guard';
import { CitiesService } from './cities.service';
import { CityResponseDto, DistrictResponseDto } from './dto/city-response.dto';
import { CreateCityDto, CreateDistrictDto } from './dto/create-city.dto';
@ApiTags('cities')
@Controller('cities')
@@ -34,7 +35,7 @@ export class CitiesController {
@Post()
@ApiOperation({ summary: 'Create city (admin only)' })
@ApiResponse({ status: 201, type: CityResponseDto })
createCity(@Body() body: { name: string; lat: number; lng: number }) {
createCity(@Body() body: CreateCityDto) {
return this.citiesService.createCity(body.name, body.lat, body.lng);
}
@@ -44,7 +45,7 @@ export class CitiesController {
@Post(':cityId/districts')
@ApiOperation({ summary: 'Create district (admin only)' })
@ApiResponse({ status: 201, type: DistrictResponseDto })
createDistrict(@Param('cityId') cityId: string, @Body() body: { name: string }) {
createDistrict(@Param('cityId') cityId: string, @Body() body: CreateDistrictDto) {
return this.citiesService.createDistrict(cityId, body.name);
}
}

View File

@@ -0,0 +1,17 @@
import { ApiProperty } from '@nestjs/swagger';
export class CreateCityDto {
@ApiProperty({ example: 'Москва' })
name: string;
@ApiProperty({ example: 55.7558 })
lat: number;
@ApiProperty({ example: 37.6173 })
lng: number;
}
export class CreateDistrictDto {
@ApiProperty({ example: 'Центральный' })
name: string;
}

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Public } from '../../common/decorators/public.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -26,6 +26,7 @@ export class GreetingsController {
@Roles('admin')
@Post()
@ApiOperation({ summary: 'Add greeting phrase (admin only)' })
@ApiBody({ schema: { type: 'object', properties: { text: { type: 'string', example: 'Привет!' } }, required: ['text'] } })
@ApiResponse({ status: 201, type: GreetingDto })
create(@Body('text') text: string) {
return this.greetingsService.create(text);

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Public } from '../../common/decorators/public.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -26,6 +26,7 @@ export class TagsController {
@Roles('admin')
@Post()
@ApiOperation({ summary: 'Create tag (admin only)' })
@ApiBody({ schema: { type: 'object', properties: { value: { type: 'string', example: 'Спорт' } }, required: ['value'] } })
@ApiResponse({ status: 201, type: TagResponseDto })
create(@Body('value') value: string) {
return this.tagsService.create(value);