| import { Controller, Post, Get, Put, Body, Param, UseGuards } from '@nestjs/common'; |
| import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; |
| import { BidsService } from './bids.service'; |
| import { JwtAuthGuard } from '../common/guards/jwt-auth.guard'; |
| import { RolesGuard } from '../common/guards/roles.guard'; |
| import { Roles } from '../common/decorators/roles.decorator'; |
| import { CurrentUser } from '../common/decorators/current-user.decorator'; |
| import { CreateBidDto } from './dto/create-bid.dto'; |
| import { UpdateBidDto } from './dto/update-bid.dto'; |
| import { TechReviewDto } from './dto/tech-review.dto'; |
| import { CeoDecisionDto } from './dto/ceo-decision.dto'; |
| import { CounterOfferDto } from './dto/counter-offer.dto'; |
|
|
| @ApiTags('Bids') |
| @Controller('bids') |
| @UseGuards(JwtAuthGuard, RolesGuard) |
| |
| @Roles('CLIENT', 'EXPERT', 'ADMIN') |
| export class BidsController { |
| constructor(private readonly bidsService: BidsService) {} |
|
|
| @ApiBearerAuth('JWT') |
| @Post() |
| |
| @Roles('EXPERT') |
| async create(@CurrentUser() user: { id: string }, @Body() body: CreateBidDto) { |
| return this.bidsService.create(user.id, body); |
| } |
|
|
| @ApiBearerAuth('JWT') |
| @Get(':id') |
| |
| |
| async findById( |
| @CurrentUser() user: { id: string; activeRole: string; clientSubtype?: string }, |
| @Param('id') id: string, |
| ) { |
| return this.bidsService.findById(id, user); |
| } |
|
|
| @ApiBearerAuth('JWT') |
| @Put(':id') |
| |
| @Roles('EXPERT') |
| async update( |
| @CurrentUser() user: { id: string }, |
| @Param('id') id: string, |
| @Body() body: UpdateBidDto, |
| ) { |
| return this.bidsService.update(id, user.id, body); |
| } |
|
|
| @ApiBearerAuth('JWT') |
| @Put(':id/tech-review') |
| |
| |
| |
| @Roles('CLIENT') |
| async techReview( |
| @CurrentUser() user: { id: string; activeRole: string; clientSubtype?: string }, |
| @Param('id') id: string, |
| @Body() body: TechReviewDto, |
| ) { |
| return this.bidsService.techReview(id, user, body); |
| } |
|
|
| @ApiBearerAuth('JWT') |
| @Put(':id/ceo-decision') |
| |
| @Roles('CLIENT') |
| async ceoDecision( |
| @CurrentUser() user: { id: string; activeRole: string; clientSubtype?: string }, |
| @Param('id') id: string, |
| @Body() body: CeoDecisionDto, |
| ) { |
| return this.bidsService.ceoDecision(id, user, body); |
| } |
|
|
| @ApiBearerAuth('JWT') |
| @Put(':id/counter-offer') |
| |
| @Roles('CLIENT') |
| async counterOffer( |
| @CurrentUser() user: { id: string; activeRole: string; clientSubtype?: string }, |
| @Param('id') id: string, |
| @Body() body: CounterOfferDto, |
| ) { |
| return this.bidsService.counterOffer(id, user, body); |
| } |
| } |
|
|