59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Patch,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { Prisma } from '@prisma/client';
|
|
import { SmartAdvisorService } from './smart-advisor.service';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { RolesGuard } from '../common/guards/roles.guard';
|
|
import { Roles } from '../common/decorators/roles.decorator';
|
|
|
|
@ApiTags('Smart Advisor - دستیار هوشمند توصیه دارویی')
|
|
@Controller('smart-advisor/rules')
|
|
export class SmartAdvisorController {
|
|
constructor(private readonly smartAdvisorService: SmartAdvisorService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'لیست قانونهای دستیار هوشمند' })
|
|
findAll() {
|
|
return this.smartAdvisorService.findAll();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('Admin')
|
|
@ApiBearerAuth()
|
|
@Post()
|
|
@ApiOperation({ summary: 'ایجاد قانون جدید دستیار هوشمند (نیازمند ادمین)' })
|
|
create(@Body() body: Prisma.SmartAdvisorRuleCreateInput) {
|
|
return this.smartAdvisorService.create(body);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('Admin')
|
|
@ApiBearerAuth()
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'ویرایش قانون دستیار هوشمند (نیازمند ادمین)' })
|
|
update(
|
|
@Param('id') id: string,
|
|
@Body() body: Prisma.SmartAdvisorRuleUpdateInput,
|
|
) {
|
|
return this.smartAdvisorService.update(id, body);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('Admin')
|
|
@ApiBearerAuth()
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: 'حذف قانون دستیار هوشمند (نیازمند ادمین)' })
|
|
remove(@Param('id') id: string) {
|
|
return this.smartAdvisorService.remove(id);
|
|
}
|
|
}
|