changes on db initializing, add pipevalidation for status

main
buuwie 9 months ago
parent c8b64c21ff
commit bea9ba2a59
  1. 40
      cartier_catalog1.csv
  2. 2
      package-lock.json
  3. 2
      package.json
  4. 13
      src/csv/csv.controller.ts
  5. 35
      src/csv/csv.service.ts
  6. 17
      src/dto/createProduct.dto.ts
  7. 22
      src/dto/editProduct.dto.ts
  8. 24
      src/entity/csv.entity.ts
  9. 22
      src/productStatusValidation.pipe.ts
  10. 26
      uploads/2878a4961cf985939bb451259c5e84bf
  11. 26
      uploads/99d1a675242916ac0df3d1dc7a61669d
  12. 40
      uploads/a133887a374d6f28990de27f74f6980c

@ -0,0 +1,40 @@
serial,name,category,size,description,status,manufactureDate,warranty
B4084600,Love ring,rings,Pair/Single,"Love ring, 18K yellow gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084900,Love ring,rings,Single,"Love ring, 950/1000 platinum. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084800,Love ring,rings,Single,"Love ring, 18K rose gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084700,Love ring,rings,Pair/Single,"Love ring, 18K white gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4085000,Love wedding band,rings,Pair,"Love wedding band, 18K yellow gold. Width: 3.6mm.",Out of stock,19-02-2024,Lorem ipsum
B4085200,Love wedding band,rings,Pair,"Love wedding band, 18K rose gold. Width: 3.6mm.",Available,19-02-2024,Lorem ipsum
B4085100,Love wedding band,rings,Pair/Single,"Love wedding band, 18K white gold. Width: 3.6mm.",Out of stock,19-02-2024,Lorem ipsum
B4085300,Love wedding band,rings,Pair/Single,"Love wedding band, 950/1000 platinum. Width: 3.6mm.",Available,19-02-2024,Lorem ipsum
B4032400,"Love ring, 3 diamonds",rings,Single,"Love ring, 18K yellow gold, set with 3 brilliant-cut diamonds totaling 0.22 carats. Width: 5.5mm.",Out of stock,19-02-2024,Lorem ipsum
B6044017,"Amulette de Cartier bracelet, XS model",bracelets,Single,"Amulette de Cartier bracelet, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm.",Available,19-02-2024,Lorem ipsum
B6047117,"Amulette de Cartier bracelet, XS model",bracelets,Pair/Single,"Amulette de Cartier bracelet, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B6044117,"Amulette de Cartier bracelet, XS model",bracelets,Single,"Amulette de Cartier bracelet, XS model, 18K pink gold, set with a brilliant-cut diamond of 0.02 carats, onyx. Diameter of motif: 12 mm.",Available,19-02-2024,Lorem ipsum
B6050717,"Amulette de Cartier bracelet, XS model",bracelets,Pair/Single,"Amulette de Cartier bracelet, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B6035517,Love bracelet,bracelets,Single,"Love bracelet, 18K yellow gold. Sold with a screwdriver. Width: 6.1mm.",Available,19-02-2024,Lorem ipsum
N6036917,"Love bracelet, diamond-paved",bracelets,Pair/Single,"Love bracelet, 18K pink gold, set with 204 brilliant-cut diamonds totaling 1.99 carats.",Available,19-02-2024,Lorem ipsum
B6035617,Love bracelet,bracelets,Pair/Single,"Love bracelet, 18K rose gold. Sold with a screwdriver. Width: 6.1mm.",Available,19-02-2024,Lorem ipsum
B6035417,Love bracelet,bracelets,Pair/Single,"Love bracelet, 18K white gold. Sold with a screwdriver. Width: 6.1mm.",Out of stock,19-02-2024,Lorem ipsum
B6047517,"Love bracelet, SM",bracelets,Single,"Love bracelet, small model, 18K yellow gold. Sold with a screwdriver. Width: 3.65mm.",Available,19-02-2024,Lorem ipsum
B6047317,"Love bracelet, SM",bracelets,Pair/Single,"Love bracelet, small model, 18K rose gold. Sold with a screwdriver. Width: 3.65mm.",Out of stock,19-02-2024,Lorem ipsum
B3047100,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B3047200,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, onyx, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Out of stock,19-02-2024,Lorem ipsum
B7224550,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B7224569,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm. Adjustable chain.",Out of stock,19-02-2024,Lorem ipsum
B7224558,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K pink gold, set with a brilliant-cut diamond of 0.09 carats, onyx.",Available,19-02-2024,Lorem ipsum
B7224521,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm.",Available,19-02-2024,Lorem ipsum
B7224518,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, carnelian, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B3153108,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Out of stock,19-02-2024,Lorem ipsum
B7224520,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, chrysoprase, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B7224542,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm.",Out of stock,19-02-2024,Lorem ipsum
B8301238,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301230,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B8301239,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301229,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301251,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, extra-small model, 18K pink gold, onyx, white mother-of-pearl, each set with 2 brilliant-cut diamond totaling 0.11 carat. Motif diameter: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B8301421,Love single earring,earrings,Pair/Single,"Love single earring, 18K yellow gold. Diameter 6 mm. Sold individually.",Available,19-02-2024,Lorem ipsum
B8301422,Love single earring,earrings,Pair/Single,"Love single earring, 18K pink gold. Diameter 12mm. Sold individually.",Available,19-02-2024,Lorem ipsum
B8301254,Love earrings,earrings,Pair/Single,"Love earrings, 18K rose gold. Inner diameter 7.2mm.",Out of stock,19-02-2024,Lorem ipsum
B8301255,Love earrings,earrings,Pair/Single,"Love earrings, 18K yellow gold. Inner diameter 7.2mm.",Available,19-02-2024,Lorem ipsum
B8301256,Love earrings,earrings,Pair/Single,"Love earrings, 18K white gold. Inner diameter 7.2mm.",Available,19-02-2024,Lorem ipsum
1 serial name category size description status manufactureDate warranty
2 B4084600 Love ring rings Pair/Single Love ring, 18K yellow gold. Width: 5.5mm. Available 19-02-2024 Lorem ipsum
3 B4084900 Love ring rings Single Love ring, 950/1000 platinum. Width: 5.5mm. Available 19-02-2024 Lorem ipsum
4 B4084800 Love ring rings Single Love ring, 18K rose gold. Width: 5.5mm. Available 19-02-2024 Lorem ipsum
5 B4084700 Love ring rings Pair/Single Love ring, 18K white gold. Width: 5.5mm. Available 19-02-2024 Lorem ipsum
6 B4085000 Love wedding band rings Pair Love wedding band, 18K yellow gold. Width: 3.6mm. Out of stock 19-02-2024 Lorem ipsum
7 B4085200 Love wedding band rings Pair Love wedding band, 18K rose gold. Width: 3.6mm. Available 19-02-2024 Lorem ipsum
8 B4085100 Love wedding band rings Pair/Single Love wedding band, 18K white gold. Width: 3.6mm. Out of stock 19-02-2024 Lorem ipsum
9 B4085300 Love wedding band rings Pair/Single Love wedding band, 950/1000 platinum. Width: 3.6mm. Available 19-02-2024 Lorem ipsum
10 B4032400 Love ring, 3 diamonds rings Single Love ring, 18K yellow gold, set with 3 brilliant-cut diamonds totaling 0.22 carats. Width: 5.5mm. Out of stock 19-02-2024 Lorem ipsum
11 B6044017 Amulette de Cartier bracelet, XS model bracelets Single Amulette de Cartier bracelet, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm. Available 19-02-2024 Lorem ipsum
12 B6047117 Amulette de Cartier bracelet, XS model bracelets Pair/Single Amulette de Cartier bracelet, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Out of stock 19-02-2024 Lorem ipsum
13 B6044117 Amulette de Cartier bracelet, XS model bracelets Single Amulette de Cartier bracelet, XS model, 18K pink gold, set with a brilliant-cut diamond of 0.02 carats, onyx. Diameter of motif: 12 mm. Available 19-02-2024 Lorem ipsum
14 B6050717 Amulette de Cartier bracelet, XS model bracelets Pair/Single Amulette de Cartier bracelet, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm. Out of stock 19-02-2024 Lorem ipsum
15 B6035517 Love bracelet bracelets Single Love bracelet, 18K yellow gold. Sold with a screwdriver. Width: 6.1mm. Available 19-02-2024 Lorem ipsum
16 N6036917 Love bracelet, diamond-paved bracelets Pair/Single Love bracelet, 18K pink gold, set with 204 brilliant-cut diamonds totaling 1.99 carats. Available 19-02-2024 Lorem ipsum
17 B6035617 Love bracelet bracelets Pair/Single Love bracelet, 18K rose gold. Sold with a screwdriver. Width: 6.1mm. Available 19-02-2024 Lorem ipsum
18 B6035417 Love bracelet bracelets Pair/Single Love bracelet, 18K white gold. Sold with a screwdriver. Width: 6.1mm. Out of stock 19-02-2024 Lorem ipsum
19 B6047517 Love bracelet, SM bracelets Single Love bracelet, small model, 18K yellow gold. Sold with a screwdriver. Width: 3.65mm. Available 19-02-2024 Lorem ipsum
20 B6047317 Love bracelet, SM bracelets Pair/Single Love bracelet, small model, 18K rose gold. Sold with a screwdriver. Width: 3.65mm. Out of stock 19-02-2024 Lorem ipsum
21 B3047100 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Available 19-02-2024 Lorem ipsum
22 B3047200 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K pink gold, onyx, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Out of stock 19-02-2024 Lorem ipsum
23 B7224550 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Available 19-02-2024 Lorem ipsum
24 B7224569 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm. Adjustable chain. Out of stock 19-02-2024 Lorem ipsum
25 B7224558 Amulette de Cartier necklace, small model necklaces Single Amulette de Cartier necklace, small model, 18K pink gold, set with a brilliant-cut diamond of 0.09 carats, onyx. Available 19-02-2024 Lorem ipsum
26 B7224521 Amulette de Cartier necklace, small model necklaces Single Amulette de Cartier necklace, small model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm. Available 19-02-2024 Lorem ipsum
27 B7224518 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K pink gold, carnelian, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Available 19-02-2024 Lorem ipsum
28 B3153108 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Out of stock 19-02-2024 Lorem ipsum
29 B7224520 Amulette de Cartier necklace, XS model necklaces Single Amulette de Cartier necklace, XS model, 18K yellow gold, chrysoprase, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm. Available 19-02-2024 Lorem ipsum
30 B7224542 Amulette de Cartier necklace, small model necklaces Single Amulette de Cartier necklace, small model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm. Out of stock 19-02-2024 Lorem ipsum
31 B8301238 Amulette de Cartier earrings, XS model earrings Pair/Single Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm. Available 19-02-2024 Lorem ipsum
32 B8301230 Amulette de Cartier earrings, XS model earrings Pair/Single Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm. Out of stock 19-02-2024 Lorem ipsum
33 B8301239 Amulette de Cartier earrings, XS model earrings Pair/Single Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm. Available 19-02-2024 Lorem ipsum
34 B8301229 Amulette de Cartier earrings, XS model earrings Pair/Single Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm. Available 19-02-2024 Lorem ipsum
35 B8301251 Amulette de Cartier earrings, XS model earrings Pair/Single Amulette de Cartier earrings, extra-small model, 18K pink gold, onyx, white mother-of-pearl, each set with 2 brilliant-cut diamond totaling 0.11 carat. Motif diameter: 12 mm. Out of stock 19-02-2024 Lorem ipsum
36 B8301421 Love single earring earrings Pair/Single Love single earring, 18K yellow gold. Diameter 6 mm. Sold individually. Available 19-02-2024 Lorem ipsum
37 B8301422 Love single earring earrings Pair/Single Love single earring, 18K pink gold. Diameter 12mm. Sold individually. Available 19-02-2024 Lorem ipsum
38 B8301254 Love earrings earrings Pair/Single Love earrings, 18K rose gold. Inner diameter 7.2mm. Out of stock 19-02-2024 Lorem ipsum
39 B8301255 Love earrings earrings Pair/Single Love earrings, 18K yellow gold. Inner diameter 7.2mm. Available 19-02-2024 Lorem ipsum
40 B8301256 Love earrings earrings Pair/Single Love earrings, 18K white gold. Inner diameter 7.2mm. Available 19-02-2024 Lorem ipsum

2
package-lock.json generated

@ -1,5 +1,5 @@
{ {
"name": "csv-import", "name": "csvimport",
"version": "0.0.1", "version": "0.0.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,

@ -1,5 +1,5 @@
{ {
"name": "csv-import", "name": "csvimport",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "",
"author": "", "author": "",

@ -5,6 +5,9 @@ import * as csv from 'csv-parser';
import { CsvService } from './csv.service'; import { CsvService } from './csv.service';
import { CreateProductDto } from 'src/dto/createProduct.dto'; import { CreateProductDto } from 'src/dto/createProduct.dto';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { productStatus } from 'src/entity/csv.entity';
import { EditProductDto } from 'src/dto/editProduct.dto';
import { ProductStatusValidationPipe } from 'src/productStatusValidation.pipe';
@Controller('file') @Controller('file')
@ -34,17 +37,17 @@ export class CsvController {
return this.csvService.getOneData(id); return this.csvService.getOneData(id);
} }
@Post('data/create') @Post('data')
createProduct (@Body(ValidationPipe) data: CreateProductDto) { createProduct (@Body(ValidationPipe) data: CreateProductDto) {
return this.csvService.createData(data); return this.csvService.createData(data);
} }
@Patch('data/edit/:id') @Patch('data/:id')
updateProduct (@Param('id') id: number, @Body('name') name: string, @Body('sku') sku: string, @Body('price') price: string) { updateProduct (@Param('id') id: number, @Body(ValidationPipe) data: EditProductDto, @Body("status", ProductStatusValidationPipe) status: productStatus) {
return this.csvService.editData(id, name, sku, price); return this.csvService.editData(id, data, status);
} }
@Delete('data/delete/:id') @Delete('data/:id')
deleteProduct(@Param('id') id: number) { deleteProduct(@Param('id') id: number) {
return this.csvService.deleteData(id); return this.csvService.deleteData(id);
} }

@ -3,7 +3,8 @@ import { InjectRepository } from '@nestjs/typeorm';
import * as csv from 'csv-parser'; import * as csv from 'csv-parser';
import { createReadStream } from 'fs'; import { createReadStream } from 'fs';
import { CreateProductDto } from 'src/dto/createProduct.dto'; import { CreateProductDto } from 'src/dto/createProduct.dto';
import { CsvEntity } from 'src/entity/csv.entity'; import { EditProductDto } from 'src/dto/editProduct.dto';
import { CsvEntity, productStatus } from 'src/entity/csv.entity';
import { UserEntity } from 'src/entity/user.entity'; import { UserEntity } from 'src/entity/user.entity';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
@ -20,8 +21,13 @@ export class CsvService {
for (const result of results) { for (const result of results) {
const csvData = new CsvEntity(); const csvData = new CsvEntity();
csvData.name = result.name; csvData.name = result.name;
csvData.sku = result.sku; csvData.serial = result.serial;
csvData.price = result.price; csvData.category = result.category;
csvData.size = result.size;
csvData.description = result.description;
csvData.status = result.status;
csvData.manufactureDate = result.manufactureDate;
csvData.warranty = result.warranty;
await this.repo.save(csvData); await this.repo.save(csvData);
} }
console.log(results); console.log(results);
@ -39,21 +45,32 @@ export class CsvService {
async createData (CreateProductDto: CreateProductDto) { async createData (CreateProductDto: CreateProductDto) {
const product = new CsvEntity(); const product = new CsvEntity();
const { name, sku, price} = CreateProductDto; const { name, serial, category, size, description, manufactureDate, warranty } = CreateProductDto;
product.name = name; product.name = name;
product.sku = sku; product.serial = serial;
product.price = price; product.category = category;
product.size = size;
product.description = description;
product.status = productStatus.AVAILABLE;
product.manufactureDate = new Date().toLocaleString();
product.warranty = warranty;
this.repo.create(product); this.repo.create(product);
return await this.repo.save(product); return await this.repo.save(product);
} }
async editData (id: number, name: string, sku: string, price: string) { async editData (id: number, EditProductDto: EditProductDto, status: productStatus) {
const product = await this.repo.findOne({where: {id: id}}); const product = await this.repo.findOne({where: {id: id}});
const { name, serial, category, size, description, manufactureDate, warranty } = EditProductDto;
if (product) { if (product) {
product.name = name; product.name = name;
product.sku = sku; product.serial = serial;
product.price = price; product.category = category;
product.size = size;
product.description = description;
product.manufactureDate = manufactureDate;
product.status = status;
product.warranty = warranty;
return this.repo.save(product); return this.repo.save(product);
} }
else throw new InternalServerErrorException('Product not found'); else throw new InternalServerErrorException('Product not found');

@ -1,4 +1,5 @@
import { IsNotEmpty } from "class-validator" import { IsNotEmpty } from "class-validator"
import { productStatus } from "src/entity/csv.entity";
export class CreateProductDto { export class CreateProductDto {
@ -6,8 +7,20 @@ export class CreateProductDto {
name: string; name: string;
@IsNotEmpty() @IsNotEmpty()
sku: string; serial: string;
@IsNotEmpty() @IsNotEmpty()
price: string; category: string;
@IsNotEmpty()
size: string;
@IsNotEmpty()
description: string;
@IsNotEmpty()
manufactureDate: string;
@IsNotEmpty()
warranty: string;
} }

@ -0,0 +1,22 @@
import { IsNotEmpty } from "class-validator"
import { productStatus } from "src/entity/csv.entity";
export class EditProductDto {
name: string;
serial: string;
category: string;
size: string;
description: string;
@IsNotEmpty()
status: productStatus;
manufactureDate: string;
warranty: string;
}

@ -5,12 +5,32 @@ export class CsvEntity {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id: number; id: number;
@Column({nullable: true})
serial: string;
@Column({nullable: true}) @Column({nullable: true})
name: string; name: string;
@Column({nullable: true}) @Column({nullable: true})
sku: string; category: string;
@Column({nullable: true})
size: string;
@Column({nullable: true})
description: string;
@Column({nullable: true}) @Column({nullable: true})
price: string; status: productStatus;
@Column({nullable: true})
manufactureDate: string;
@Column({nullable: true})
warranty: string;
}
export enum productStatus {
AVAILABLE = 'AVAILABLE',
OUT_OF_STOCK = 'OUT_OF_STOCK'
} }

@ -0,0 +1,22 @@
import { ArgumentMetadata, BadRequestException, PipeTransform } from "@nestjs/common";
import { productStatus } from "./entity/csv.entity";
export class ProductStatusValidationPipe implements PipeTransform {
readonly allowedStatus = [productStatus.AVAILABLE, productStatus.OUT_OF_STOCK];
transform(value: any, metadata: ArgumentMetadata): any {
value = value.toUpperCase();
if (!this.isStatusValid(value)) {
throw new BadRequestException(`${value} is an invalid status.`);
}
return value;
}
private isStatusValid(status : any) {
const index = this.allowedStatus.indexOf(status);
return index !== -1;
}
}

@ -0,0 +1,26 @@
Name,SKU,Regular price
V-Neck T-Shirt,woo-vneck-tee,
Hoodie,woo-hoodie,
Hoodie with Logo,woo-hoodie-with-logo,45
T-Shirt,woo-tshirt,18
Beanie,woo-beanie,20
Belt,woo-belt,65
Cap,woo-cap,18
Sunglasses,woo-sunglasses,90
Hoodie with Pocket,woo-hoodie-with-pocket,45
Hoodie with Zipper,woo-hoodie-with-zipper,45
Long Sleeve Tee,woo-long-sleeve-tee,25
Polo,woo-polo,20
Album,woo-album,15
Single,woo-single,3
V-Neck T-Shirt - Red,woo-vneck-tee-red,20
V-Neck T-Shirt - Green,woo-vneck-tee-green,20
V-Neck T-Shirt - Blue,woo-vneck-tee-blue,15
"Hoodie - Red, No",woo-hoodie-red,45
"Hoodie - Green, No",woo-hoodie-green,45
"Hoodie - Blue, No",woo-hoodie-blue,45
T-Shirt with Logo,Woo-tshirt-logo,18
Beanie with Logo,Woo-beanie-logo,20
Logo Collection,logo-collection,
WordPress Pennant,wp-pennant,11.05
"Hoodie - Blue, Yes",woo-hoodie-blue-logo,45

@ -0,0 +1,26 @@
Name,SKU,Regular price
V-Neck T-Shirt,woo-vneck-tee,
Hoodie,woo-hoodie,
Hoodie with Logo,woo-hoodie-with-logo,45
T-Shirt,woo-tshirt,18
Beanie,woo-beanie,20
Belt,woo-belt,65
Cap,woo-cap,18
Sunglasses,woo-sunglasses,90
Hoodie with Pocket,woo-hoodie-with-pocket,45
Hoodie with Zipper,woo-hoodie-with-zipper,45
Long Sleeve Tee,woo-long-sleeve-tee,25
Polo,woo-polo,20
Album,woo-album,15
Single,woo-single,3
V-Neck T-Shirt - Red,woo-vneck-tee-red,20
V-Neck T-Shirt - Green,woo-vneck-tee-green,20
V-Neck T-Shirt - Blue,woo-vneck-tee-blue,15
"Hoodie - Red, No",woo-hoodie-red,45
"Hoodie - Green, No",woo-hoodie-green,45
"Hoodie - Blue, No",woo-hoodie-blue,45
T-Shirt with Logo,Woo-tshirt-logo,18
Beanie with Logo,Woo-beanie-logo,20
Logo Collection,logo-collection,
WordPress Pennant,wp-pennant,11.05
"Hoodie - Blue, Yes",woo-hoodie-blue-logo,45

@ -0,0 +1,40 @@
serial,name,category,size,description,status,manufactureDate,warranty
B4084600,Love ring,rings,Pair/Single,"Love ring, 18K yellow gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084900,Love ring,rings,Single,"Love ring, 950/1000 platinum. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084800,Love ring,rings,Single,"Love ring, 18K rose gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4084700,Love ring,rings,Pair/Single,"Love ring, 18K white gold. Width: 5.5mm.",Available,19-02-2024,Lorem ipsum
B4085000,Love wedding band,rings,Pair,"Love wedding band, 18K yellow gold. Width: 3.6mm.",Out of stock,19-02-2024,Lorem ipsum
B4085200,Love wedding band,rings,Pair,"Love wedding band, 18K rose gold. Width: 3.6mm.",Available,19-02-2024,Lorem ipsum
B4085100,Love wedding band,rings,Pair/Single,"Love wedding band, 18K white gold. Width: 3.6mm.",Out of stock,19-02-2024,Lorem ipsum
B4085300,Love wedding band,rings,Pair/Single,"Love wedding band, 950/1000 platinum. Width: 3.6mm.",Available,19-02-2024,Lorem ipsum
B4032400,"Love ring, 3 diamonds",rings,Single,"Love ring, 18K yellow gold, set with 3 brilliant-cut diamonds totaling 0.22 carats. Width: 5.5mm.",Out of stock,19-02-2024,Lorem ipsum
B6044017,"Amulette de Cartier bracelet, XS model",bracelets,Single,"Amulette de Cartier bracelet, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm.",Available,19-02-2024,Lorem ipsum
B6047117,"Amulette de Cartier bracelet, XS model",bracelets,Pair/Single,"Amulette de Cartier bracelet, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B6044117,"Amulette de Cartier bracelet, XS model",bracelets,Single,"Amulette de Cartier bracelet, XS model, 18K pink gold, set with a brilliant-cut diamond of 0.02 carats, onyx. Diameter of motif: 12 mm.",Available,19-02-2024,Lorem ipsum
B6050717,"Amulette de Cartier bracelet, XS model",bracelets,Pair/Single,"Amulette de Cartier bracelet, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B6035517,Love bracelet,bracelets,Single,"Love bracelet, 18K yellow gold. Sold with a screwdriver. Width: 6.1mm.",Available,19-02-2024,Lorem ipsum
N6036917,"Love bracelet, diamond-paved",bracelets,Pair/Single,"Love bracelet, 18K pink gold, set with 204 brilliant-cut diamonds totaling 1.99 carats.",Available,19-02-2024,Lorem ipsum
B6035617,Love bracelet,bracelets,Pair/Single,"Love bracelet, 18K rose gold. Sold with a screwdriver. Width: 6.1mm.",Available,19-02-2024,Lorem ipsum
B6035417,Love bracelet,bracelets,Pair/Single,"Love bracelet, 18K white gold. Sold with a screwdriver. Width: 6.1mm.",Out of stock,19-02-2024,Lorem ipsum
B6047517,"Love bracelet, SM",bracelets,Single,"Love bracelet, small model, 18K yellow gold. Sold with a screwdriver. Width: 3.65mm.",Available,19-02-2024,Lorem ipsum
B6047317,"Love bracelet, SM",bracelets,Pair/Single,"Love bracelet, small model, 18K rose gold. Sold with a screwdriver. Width: 3.65mm.",Out of stock,19-02-2024,Lorem ipsum
B3047100,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, set with a brilliant-cut diamond of 0.02 carats, white mother-of-pearl. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B3047200,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, onyx, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Out of stock,19-02-2024,Lorem ipsum
B7224550,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B7224569,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, extra-small model, 18K pink gold, onyx, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of the motifs: 12 mm. Adjustable chain.",Out of stock,19-02-2024,Lorem ipsum
B7224558,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K pink gold, set with a brilliant-cut diamond of 0.09 carats, onyx.",Available,19-02-2024,Lorem ipsum
B7224521,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm.",Available,19-02-2024,Lorem ipsum
B7224518,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K pink gold, carnelian, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B3153108,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, lapis lazuli, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Out of stock,19-02-2024,Lorem ipsum
B7224520,"Amulette de Cartier necklace, XS model",necklaces,Single,"Amulette de Cartier necklace, XS model, 18K yellow gold, chrysoprase, set with a brilliant-cut diamond of 0.02 carats. Diameter of motif: 12 mm. Adjustable chain: 38-41 cm.",Available,19-02-2024,Lorem ipsum
B7224542,"Amulette de Cartier necklace, small model",necklaces,Single,"Amulette de Cartier necklace, small model, 18K pink gold, malachite, set with a brilliant-cut diamond of 0.09 carats. Diameter of motif: 17 mm. Chain: 60 cm.",Out of stock,19-02-2024,Lorem ipsum
B8301238,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301230,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B8301239,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K pink gold, onyx, set with 2 brilliant-cut diamonds totaling 0.05 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301229,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, XS model, 18K yellow gold, white mother-of-pearl, set with 4 brilliant-cut diamonds totaling 0.14 carats. Diameter of motifs: 12 mm.",Available,19-02-2024,Lorem ipsum
B8301251,"Amulette de Cartier earrings, XS model",earrings,Pair/Single,"Amulette de Cartier earrings, extra-small model, 18K pink gold, onyx, white mother-of-pearl, each set with 2 brilliant-cut diamond totaling 0.11 carat. Motif diameter: 12 mm.",Out of stock,19-02-2024,Lorem ipsum
B8301421,Love single earring,earrings,Pair/Single,"Love single earring, 18K yellow gold. Diameter 6 mm. Sold individually.",Available,19-02-2024,Lorem ipsum
B8301422,Love single earring,earrings,Pair/Single,"Love single earring, 18K pink gold. Diameter 12mm. Sold individually.",Available,19-02-2024,Lorem ipsum
B8301254,Love earrings,earrings,Pair/Single,"Love earrings, 18K rose gold. Inner diameter 7.2mm.",Out of stock,19-02-2024,Lorem ipsum
B8301255,Love earrings,earrings,Pair/Single,"Love earrings, 18K yellow gold. Inner diameter 7.2mm.",Available,19-02-2024,Lorem ipsum
B8301256,Love earrings,earrings,Pair/Single,"Love earrings, 18K white gold. Inner diameter 7.2mm.",Available,19-02-2024,Lorem ipsum
Loading…
Cancel
Save