up
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, ValidationPipe, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ApiNotFoundResponse,
|
ApiNotFoundResponse,
|
||||||
ApiParam,
|
ApiParam,
|
||||||
ApiBody,
|
ApiBody,
|
||||||
ApiQuery,
|
ApiBearerAuth,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { ScheduleService } from '../providers/schedule.service';
|
import { ScheduleService } from '../providers/schedule.service';
|
||||||
import { CreateScheduleDto } from '../dto/create-schedule.dto';
|
import { CreateScheduleDto } from '../dto/create-schedule.dto';
|
||||||
@@ -16,52 +16,52 @@ import { Schedule } from '../entities/schedule.entity';
|
|||||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||||
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||||
|
|
||||||
@ApiTags('schedules')
|
|
||||||
@Controller('schedules')
|
|
||||||
@UseGuards(AdminAuthGuard)
|
@UseGuards(AdminAuthGuard)
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@ApiTags('admin/schedules')
|
||||||
|
@Controller('admin/schedules')
|
||||||
export class ScheduleController {
|
export class ScheduleController {
|
||||||
constructor(private readonly scheduleService: ScheduleService) {}
|
constructor(private readonly scheduleService: ScheduleService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@ApiOperation({ summary: 'ایجاد برنامه جدید' })
|
@ApiOperation({ summary: 'Create a new schedule' })
|
||||||
@ApiBody({ type: CreateScheduleDto })
|
@ApiBody({ type: CreateScheduleDto })
|
||||||
@ApiCreatedResponse({ description: 'برنامه ایجاد شد', type: Schedule })
|
@ApiCreatedResponse({ description: 'Schedule created successfully', type: Schedule })
|
||||||
create(@Body() createScheduleDto: CreateScheduleDto, @RestId() restId: string) {
|
create(@Body() createScheduleDto: CreateScheduleDto, @RestId() restId: string) {
|
||||||
return this.scheduleService.create(restId, createScheduleDto);
|
return this.scheduleService.create(restId, createScheduleDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOperation({ summary: 'لیست همه برنامهها' })
|
@ApiOperation({ summary: 'Get all schedules' })
|
||||||
@ApiQuery({ name: 'restId', required: false, type: String, description: 'شناسه رستوران برای فیلتر کردن' })
|
@ApiOkResponse({ description: 'List of schedules', type: [Schedule] })
|
||||||
@ApiOkResponse({ description: 'لیست برنامهها', type: [Schedule] })
|
|
||||||
findAll(@RestId() restId: string) {
|
findAll(@RestId() restId: string) {
|
||||||
return this.scheduleService.findAll(restId);
|
return this.scheduleService.findAll(restId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@ApiOperation({ summary: 'دریافت یک برنامه' })
|
@ApiOperation({ summary: 'Get a schedule by ID' })
|
||||||
@ApiParam({ name: 'id', description: 'شناسه برنامه' })
|
@ApiParam({ name: 'id', description: 'Schedule ID' })
|
||||||
@ApiOkResponse({ description: 'جزئیات برنامه', type: Schedule })
|
@ApiOkResponse({ description: 'Schedule details', type: Schedule })
|
||||||
@ApiNotFoundResponse({ description: 'برنامه یافت نشد' })
|
@ApiNotFoundResponse({ description: 'Schedule not found' })
|
||||||
findOne(@Param('id') id: string, @RestId() restId: string) {
|
findOne(@Param('id') id: string, @RestId() restId: string) {
|
||||||
return this.scheduleService.findOne(id, restId);
|
return this.scheduleService.findOne(id, restId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
@ApiOperation({ summary: 'بهروزرسانی برنامه' })
|
@ApiOperation({ summary: 'Update a schedule' })
|
||||||
@ApiParam({ name: 'id', description: 'شناسه برنامه' })
|
@ApiParam({ name: 'id', description: 'Schedule ID' })
|
||||||
@ApiBody({ type: UpdateScheduleDto })
|
@ApiBody({ type: UpdateScheduleDto })
|
||||||
@ApiOkResponse({ description: 'برنامه بهروز شد', type: Schedule })
|
@ApiOkResponse({ description: 'Schedule updated successfully', type: Schedule })
|
||||||
@ApiNotFoundResponse({ description: 'برنامه یافت نشد' })
|
@ApiNotFoundResponse({ description: 'Schedule not found' })
|
||||||
update(@Param('id') id: string, @Body() updateScheduleDto: UpdateScheduleDto, @RestId() restId: string) {
|
update(@Param('id') id: string, @Body() updateScheduleDto: UpdateScheduleDto, @RestId() restId: string) {
|
||||||
return this.scheduleService.update(id, restId, updateScheduleDto);
|
return this.scheduleService.update(id, restId, updateScheduleDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@ApiOperation({ summary: 'حذف برنامه' })
|
@ApiOperation({ summary: 'Delete a schedule' })
|
||||||
@ApiParam({ name: 'id', description: 'شناسه برنامه' })
|
@ApiParam({ name: 'id', description: 'Schedule ID' })
|
||||||
@ApiOkResponse({ description: 'برنامه حذف شد' })
|
@ApiOkResponse({ description: 'Schedule deleted successfully' })
|
||||||
@ApiNotFoundResponse({ description: 'برنامه یافت نشد' })
|
@ApiNotFoundResponse({ description: 'Schedule not found' })
|
||||||
remove(@Param('id') id: string, @RestId() restId: string) {
|
remove(@Param('id') id: string, @RestId() restId: string) {
|
||||||
return this.scheduleService.remove(id, restId);
|
return this.scheduleService.remove(id, restId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user