attribute
This commit is contained in:
@@ -21,6 +21,9 @@ import { CreateCategoryDto } from '../dto/create-category.dto';
|
||||
import { CategoryService } from '../providers/category.service';
|
||||
import { FindCategoriesDto } from '../dto/find-categories.dto';
|
||||
import { UpdateCategoryDto } from '../dto/update-category.dto';
|
||||
import { AttributeService } from '../providers/attribute.service';
|
||||
import { CreateAttributeDto } from '../dto/create-attribute.dto';
|
||||
import { UpdateAttributeDto } from '../dto/update-attribute.dto';
|
||||
|
||||
@ApiTags('products')
|
||||
@Controller()
|
||||
@@ -28,6 +31,7 @@ export class productController {
|
||||
constructor(
|
||||
private readonly productService: ProductService,
|
||||
private readonly categoryService: CategoryService,
|
||||
private readonly attributeService: AttributeService,
|
||||
) { }
|
||||
|
||||
|
||||
@@ -159,4 +163,57 @@ export class productController {
|
||||
removeCategory(@Param('id') id: string,) {
|
||||
return this.categoryService.remove(+id);
|
||||
}
|
||||
|
||||
/*------------------------------ Attibute ------------------------*/
|
||||
@Post('admin/product/:id/attribute')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_productS)
|
||||
@ApiOperation({ summary: 'Create a new category' })
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
@ApiBody({ type: CreateAttributeDto })
|
||||
createAttribute(@Param('id') id: string, @Body() dto: CreateAttributeDto) {
|
||||
return this.attributeService.create(+id, dto);
|
||||
}
|
||||
|
||||
@Get('admin/products/:id/attributes')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_productS)
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
@ApiOperation({ summary: 'Get list of product attributes' })
|
||||
async findProductAttributes(@Param('id') id: string) {
|
||||
return this.attributeService.findAll(+id);
|
||||
}
|
||||
|
||||
@Get('admin/products/attributes/:id')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_productS)
|
||||
@ApiOperation({ summary: 'Get a category by id' })
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
findAttributeById(@Param('id') id: string) {
|
||||
return this.attributeService.findById(+id);
|
||||
}
|
||||
|
||||
@Patch('admin/products/attributes/:id')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_productS)
|
||||
@ApiOperation({ summary: 'Update a attribute' })
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
@ApiBody({ type: UpdateAttributeDto })
|
||||
updateProductAttribute(@Param('id') id: string, @Body() dto: UpdateAttributeDto) {
|
||||
return this.attributeService.update(+id, dto);
|
||||
}
|
||||
|
||||
@Delete('admin/products/attributes/:id')
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_productS)
|
||||
@ApiOperation({ summary: 'Delete (soft) a attribute' })
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
removeAttribute(@Param('id') id: string,) {
|
||||
return this.attributeService.remove(+id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user