fix(admin-products): add class-validator ProductDto to allow product creation and updates through ValidationPipe
Deploy Canina / deploy (push) Successful in 32s
Deploy Canina / deploy (push) Successful in 32s
This commit is contained in:
1 parent
4cbde63b89
commit
d5c05b7577
3 files changed
+176
-33
No files matched your search
@@ -9,7 +9,8 @@ import {
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AdminService, ProductInput, CouponInput } from './admin.service';
|
||||
import { AdminService, CouponInput } from './admin.service';
|
||||
import { ProductDto } from './dto/product.dto';
|
||||
import { AdminQueryDto } from './dto/admin-query.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import {
|
||||
@@ -127,14 +128,14 @@ export class AdminController {
|
||||
|
||||
@Post('products')
|
||||
@ApiOperation({ summary: 'ایجاد محصول جدید' })
|
||||
async createProduct(@Body() data: ProductInput) {
|
||||
async createProduct(@Body() data: ProductDto) {
|
||||
const product = await this.adminService.createProduct(data);
|
||||
return { success: true, data: product };
|
||||
}
|
||||
|
||||
@Put('products/:id')
|
||||
@ApiOperation({ summary: 'ویرایش محصول' })
|
||||
async updateProduct(@Param('id') id: string, @Body() data: ProductInput) {
|
||||
async updateProduct(@Param('id') id: string, @Body() data: ProductDto) {
|
||||
const product = await this.adminService.updateProduct(id, data);
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in new issue
Block a user