67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import {
|
|
Controller,
|
|
Post,
|
|
Get,
|
|
Put,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
Request,
|
|
} from '@nestjs/common';
|
|
import { WholesaleService } from './wholesale.service';
|
|
import { WholesaleApplyDto } from './dto/wholesale-apply.dto';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { RolesGuard } from '../auth/roles.guard';
|
|
import { Roles } from '../auth/roles.decorator';
|
|
|
|
@ApiTags('Wholesale - عمدهفروشی B2B')
|
|
@Controller('wholesale')
|
|
export class WholesaleController {
|
|
constructor(private readonly wholesaleService: WholesaleService) {}
|
|
|
|
@Post('apply')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiOperation({
|
|
summary: 'ثبت درخواست همکاری عمدهفروشی (ارسال پروانه کلینیک/داروخانه)',
|
|
})
|
|
applyForWholesale(
|
|
@Request() req: { user: { id: string } },
|
|
@Body() dto: WholesaleApplyDto,
|
|
) {
|
|
return this.wholesaleService.applyForWholesale(req.user.id, dto);
|
|
}
|
|
|
|
@Get('requests')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('ADMIN')
|
|
@ApiBearerAuth()
|
|
@ApiOperation({
|
|
summary: 'لیست تمام درخواستهای همکاری عمدهفروشی (مخصوص ادمین)',
|
|
})
|
|
getWholesaleRequests() {
|
|
return this.wholesaleService.getWholesaleRequests();
|
|
}
|
|
|
|
@Put('approve/:userId')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('ADMIN')
|
|
@ApiBearerAuth()
|
|
@ApiOperation({
|
|
summary: 'تایید درخواست و ارتقا به خریدار عمده (User_Wholesale)',
|
|
})
|
|
approveWholesaleRequest(@Param('userId') userId: string) {
|
|
return this.wholesaleService.approveWholesaleRequest(userId);
|
|
}
|
|
|
|
@Put('reject/:userId')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles('ADMIN')
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'رد درخواست همکاری عمدهفروشی' })
|
|
rejectWholesaleRequest(@Param('userId') userId: string) {
|
|
return this.wholesaleService.rejectWholesaleRequest(userId);
|
|
}
|
|
}
|