|
|
|
@@ -12,30 +12,30 @@ import {
|
|
|
|
|
ApiBearerAuth,
|
|
|
|
|
ApiHeader,
|
|
|
|
|
} from '@nestjs/swagger';
|
|
|
|
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
|
|
|
|
import { UserId } from 'src/common/decorators';
|
|
|
|
|
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
|
|
|
|
import { Permission } from 'src/common/enums/permission.enum';
|
|
|
|
|
import { Permissions } from 'src/common/decorators/permissions.decorator';
|
|
|
|
|
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';
|
|
|
|
|
import { CreateAttributeValueDto } from '../dto/create-attribute-value.dto';
|
|
|
|
|
import { AttributeValueService } from '../providers/attribute-value.service';
|
|
|
|
|
import { UpdateAttributeValueDto } from '../dto/update-attribute-value.dto';
|
|
|
|
|
// import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
|
|
|
|
// import { UserId } from 'src/common/decorators';
|
|
|
|
|
// import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
|
|
|
|
// import { AttributeService } from '../providers/attribute.service';
|
|
|
|
|
// import { CreateAttributeDto } from '../dto/create-attribute.dto';
|
|
|
|
|
// import { UpdateAttributeDto } from '../dto/update-attribute.dto';
|
|
|
|
|
// import { CreateAttributeValueDto } from '../dto/create-attribute-value.dto';
|
|
|
|
|
// import { AttributeValueService } from '../providers/attribute-value.service';
|
|
|
|
|
// import { UpdateAttributeValueDto } from '../dto/update-attribute-value.dto';
|
|
|
|
|
|
|
|
|
|
@ApiTags('products')
|
|
|
|
|
@Controller()
|
|
|
|
|
export class productController {
|
|
|
|
|
export class ProductController {
|
|
|
|
|
constructor(
|
|
|
|
|
private readonly productService: ProductService,
|
|
|
|
|
private readonly categoryService: CategoryService,
|
|
|
|
|
private readonly attributeService: AttributeService,
|
|
|
|
|
private readonly attributeValueService: AttributeValueService,
|
|
|
|
|
// private readonly attributeService: AttributeService,
|
|
|
|
|
// private readonly attributeValueService: AttributeValueService,
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -171,108 +171,108 @@ export class productController {
|
|
|
|
|
|
|
|
|
|
/*=============================== Attibute ==========================*/
|
|
|
|
|
|
|
|
|
|
@Post('admin/product/:id/attribute')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiOperation({ summary: 'Create a new attribute' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
@ApiBody({ type: CreateAttributeDto })
|
|
|
|
|
createAttribute(@Param('id') id: string, @Body() dto: CreateAttributeDto) {
|
|
|
|
|
return this.attributeService.create(+id, dto);
|
|
|
|
|
}
|
|
|
|
|
// @Post('admin/product/:id/attribute')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Create a new attribute' })
|
|
|
|
|
// @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/: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 attribute by id' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
findAttributeById(@Param('id') id: string) {
|
|
|
|
|
return this.attributeService.findById(+id);
|
|
|
|
|
}
|
|
|
|
|
// @Get('admin/products/attributes/:id')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Get a attribute 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);
|
|
|
|
|
}
|
|
|
|
|
// @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);
|
|
|
|
|
}
|
|
|
|
|
// @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);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/*=========================== Attibute Values==========================*/
|
|
|
|
|
@Post('admin/product/attribute/:id/value')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiOperation({ summary: 'Create a new attribute value' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
@ApiBody({ type: CreateAttributeValueDto })
|
|
|
|
|
createAttributeValue(@Param('id') id: string, @Body() dto: CreateAttributeValueDto) {
|
|
|
|
|
return this.attributeValueService.create(+id, dto);
|
|
|
|
|
}
|
|
|
|
|
// @Post('admin/product/attribute/:id/value')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Create a new attribute value' })
|
|
|
|
|
// @ApiParam({ name: 'id', required: true })
|
|
|
|
|
// @ApiBody({ type: CreateAttributeValueDto })
|
|
|
|
|
// createAttributeValue(@Param('id') id: string, @Body() dto: CreateAttributeValueDto) {
|
|
|
|
|
// return this.attributeValueService.create(+id, dto);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Get('admin/products/attributes/:id/values')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
@ApiOperation({ summary: 'Get list of attribute values' })
|
|
|
|
|
async findtAttributeValue(@Param('id') id: string) {
|
|
|
|
|
return this.attributeValueService.findAll(+id);
|
|
|
|
|
}
|
|
|
|
|
// @Get('admin/products/attributes/:id/values')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiParam({ name: 'id', required: true })
|
|
|
|
|
// @ApiOperation({ summary: 'Get list of attribute values' })
|
|
|
|
|
// async findtAttributeValue(@Param('id') id: string) {
|
|
|
|
|
// return this.attributeValueService.findAll(+id);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Get('admin/products/attributes/value/:id')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiOperation({ summary: 'Get a attribute value by id' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
findAttributeValueById(@Param('id') id: string) {
|
|
|
|
|
return this.attributeValueService.findById(+id);
|
|
|
|
|
}
|
|
|
|
|
// @Get('admin/products/attributes/value/:id')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Get a attribute value by id' })
|
|
|
|
|
// @ApiParam({ name: 'id', required: true })
|
|
|
|
|
// findAttributeValueById(@Param('id') id: string) {
|
|
|
|
|
// return this.attributeValueService.findById(+id);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Patch('admin/products/attributes/value/:id')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiOperation({ summary: 'Update a attribute value' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
@ApiBody({ type: UpdateAttributeValueDto })
|
|
|
|
|
updateAttributeValue(@Param('id') id: string, @Body() dto: UpdateAttributeValueDto) {
|
|
|
|
|
return this.attributeValueService.update(+id, dto);
|
|
|
|
|
}
|
|
|
|
|
// @Patch('admin/products/attributes/value/:id')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Update a attribute value' })
|
|
|
|
|
// @ApiParam({ name: 'id', required: true })
|
|
|
|
|
// @ApiBody({ type: UpdateAttributeValueDto })
|
|
|
|
|
// updateAttributeValue(@Param('id') id: string, @Body() dto: UpdateAttributeValueDto) {
|
|
|
|
|
// return this.attributeValueService.update(+id, dto);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Delete('admin/products/attributes/value/:id')
|
|
|
|
|
// @UseGuards(AdminAuthGuard)
|
|
|
|
|
@ApiBearerAuth()
|
|
|
|
|
@Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
@ApiOperation({ summary: 'Delete (soft) a attribute value' })
|
|
|
|
|
@ApiParam({ name: 'id', required: true })
|
|
|
|
|
removeAttributeValue(@Param('id') id: string,) {
|
|
|
|
|
return this.attributeValueService.remove(+id);
|
|
|
|
|
}
|
|
|
|
|
// @Delete('admin/products/attributes/value/:id')
|
|
|
|
|
// // @UseGuards(AdminAuthGuard)
|
|
|
|
|
// @ApiBearerAuth()
|
|
|
|
|
// @Permissions(Permission.MANAGE_PRODUCTS)
|
|
|
|
|
// @ApiOperation({ summary: 'Delete (soft) a attribute value' })
|
|
|
|
|
// @ApiParam({ name: 'id', required: true })
|
|
|
|
|
// removeAttributeValue(@Param('id') id: string,) {
|
|
|
|
|
// return this.attributeValueService.remove(+id);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|