first
This commit is contained in:
@@ -0,0 +1,438 @@
|
||||
import { Expose, Type, plainToInstance } from "class-transformer";
|
||||
import { IsString } from "class-validator";
|
||||
|
||||
import { ApiProperty } from "../../../common/decorator/swggerDocs";
|
||||
import { ProductStatus } from "../../../common/enums/product.enum";
|
||||
import { BrandDTO } from "../../brand/DTO/brand.dto";
|
||||
import { CategoryTreeDTO, ColorDTO, Size_MeterageDTO } from "../../category/DTO/category.dto";
|
||||
import { ShipmentMethodDTO } from "../../shipment/DTO/shipment.dto";
|
||||
import { ShopDTO } from "../../shop/DTO/shop.dto";
|
||||
import { WarrantyDTO } from "../../warranty/DTO/warranty.dto";
|
||||
import { IncredibleOffers } from "../models/Abstraction/IncredibleOffers";
|
||||
import { IProduct } from "../models/Abstraction/IProduct";
|
||||
import { IProductVariant } from "../models/Abstraction/IProductVariant";
|
||||
//*********************************
|
||||
class SpecificationsDTO {
|
||||
@Expose()
|
||||
title: string;
|
||||
|
||||
@Expose()
|
||||
values: string[];
|
||||
}
|
||||
//*********************************
|
||||
class ImagesUrlDTO {
|
||||
@Expose()
|
||||
cover: string;
|
||||
|
||||
@Expose()
|
||||
list: string[];
|
||||
}
|
||||
|
||||
//*********************************
|
||||
|
||||
class ProductPrice {
|
||||
@Expose()
|
||||
order_limit: number;
|
||||
@Expose()
|
||||
retailPrice: number;
|
||||
|
||||
@Expose()
|
||||
selling_price: number;
|
||||
|
||||
// @Expose()
|
||||
// shipping_fee: number;
|
||||
//specialSale
|
||||
@Expose()
|
||||
is_specialSale: boolean;
|
||||
|
||||
@Expose()
|
||||
discount_percent: number;
|
||||
|
||||
@Expose()
|
||||
specialSale_order_limit: number;
|
||||
|
||||
@Expose()
|
||||
specialSale_quantity: number;
|
||||
|
||||
@Expose()
|
||||
specialSale_endDate: string;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
|
||||
class WholeSaleRangeDTO {
|
||||
@Expose()
|
||||
from: number;
|
||||
|
||||
@Expose()
|
||||
to: number;
|
||||
|
||||
@Expose()
|
||||
price: number;
|
||||
}
|
||||
//*********************************
|
||||
|
||||
class SaleFormatDTO {
|
||||
// @Expose()
|
||||
// isWholeSale: boolean;
|
||||
|
||||
@Expose()
|
||||
@Type(() => WholeSaleRangeDTO)
|
||||
wholeSale: WholeSaleRangeDTO[];
|
||||
}
|
||||
|
||||
//#################################
|
||||
|
||||
export class ProductDetailVariantDTO {
|
||||
@Expose()
|
||||
_id: string;
|
||||
|
||||
@Expose()
|
||||
market_status: string;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductPrice)
|
||||
price: ProductPrice;
|
||||
|
||||
@Expose()
|
||||
stock: number;
|
||||
|
||||
@Expose()
|
||||
postingTime: number;
|
||||
|
||||
@Expose()
|
||||
rate: number;
|
||||
|
||||
@Expose()
|
||||
isFreeShip: boolean;
|
||||
|
||||
@Expose()
|
||||
isWholeSale: boolean;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ShopDTO)
|
||||
shop: ShopDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => SaleFormatDTO)
|
||||
saleFormat: SaleFormatDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ShipmentMethodDTO)
|
||||
shipmentMethod: ShipmentMethodDTO[];
|
||||
|
||||
@Expose()
|
||||
@Type(() => WarrantyDTO)
|
||||
warranty: WarrantyDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ColorDTO)
|
||||
color?: ColorDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Size_MeterageDTO)
|
||||
size?: Size_MeterageDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Size_MeterageDTO)
|
||||
meterage?: Size_MeterageDTO;
|
||||
}
|
||||
|
||||
//#################################
|
||||
//#################################
|
||||
|
||||
export class SellerPanelProductDTO {
|
||||
@Expose()
|
||||
_id: number;
|
||||
|
||||
@Expose()
|
||||
title_fa: string;
|
||||
|
||||
@Expose()
|
||||
title_en: string;
|
||||
|
||||
@Expose()
|
||||
seoTitle: string;
|
||||
|
||||
@Expose()
|
||||
seoDescription: string;
|
||||
|
||||
@Expose()
|
||||
description: string;
|
||||
|
||||
@Expose()
|
||||
metaDescription: string;
|
||||
|
||||
@Expose()
|
||||
shopName: string;
|
||||
|
||||
@Expose()
|
||||
shopCode: string;
|
||||
|
||||
@Expose()
|
||||
category_title_fa: string;
|
||||
|
||||
@Expose()
|
||||
category_id: string;
|
||||
|
||||
@Expose()
|
||||
brand_title_fa: string;
|
||||
|
||||
@Expose()
|
||||
status: ProductStatus;
|
||||
|
||||
@Expose()
|
||||
adminComments: string;
|
||||
|
||||
@Expose()
|
||||
step: number;
|
||||
|
||||
@Expose()
|
||||
isFake: boolean;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ImagesUrlDTO)
|
||||
imagesUrl: ImagesUrlDTO;
|
||||
|
||||
@Expose()
|
||||
variantCount: number;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductDetailVariantDTO)
|
||||
default_variant: ProductDetailVariantDTO;
|
||||
|
||||
@Expose()
|
||||
popular: boolean;
|
||||
|
||||
@Expose()
|
||||
incredible: boolean;
|
||||
|
||||
@Expose()
|
||||
voice: string;
|
||||
|
||||
public static transformProduct(data: IProduct): SellerPanelProductDTO {
|
||||
const productDTO = plainToInstance(SellerPanelProductDTO, data, {
|
||||
excludeExtraneousValues: true,
|
||||
enableImplicitConversion: true,
|
||||
});
|
||||
|
||||
return productDTO;
|
||||
}
|
||||
}
|
||||
|
||||
//#################################
|
||||
//#################################
|
||||
|
||||
export class ProductVariantDTO {
|
||||
@Expose()
|
||||
_id: string;
|
||||
|
||||
@Expose()
|
||||
product_id: number;
|
||||
|
||||
@Expose()
|
||||
title_fa: string;
|
||||
|
||||
@Expose()
|
||||
title_en: string;
|
||||
|
||||
@Expose()
|
||||
model: string;
|
||||
|
||||
@Expose()
|
||||
market_status: string;
|
||||
|
||||
@Expose()
|
||||
productCode: string;
|
||||
|
||||
@Expose()
|
||||
category_title_fa: string;
|
||||
|
||||
@Expose()
|
||||
is_variant_active: boolean;
|
||||
|
||||
@Expose()
|
||||
coverImage: string;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductPrice)
|
||||
price: ProductPrice;
|
||||
|
||||
@Expose()
|
||||
stock: number;
|
||||
|
||||
@Expose()
|
||||
sellerSpecialCode: string;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ShipmentMethodDTO)
|
||||
shipmentMethod: ShipmentMethodDTO[];
|
||||
|
||||
@Expose()
|
||||
product_status: string;
|
||||
|
||||
@Expose()
|
||||
isFreeShip: boolean;
|
||||
|
||||
@Expose()
|
||||
isWholeSale: boolean;
|
||||
|
||||
@Expose()
|
||||
@Type(() => SaleFormatDTO)
|
||||
saleFormat: SaleFormatDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ColorDTO)
|
||||
color?: ColorDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Size_MeterageDTO)
|
||||
size?: Size_MeterageDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => Size_MeterageDTO)
|
||||
meterage?: Size_MeterageDTO;
|
||||
|
||||
public static transformProduct(data: IProductVariant): ProductVariantDTO {
|
||||
const productVariantDTO = plainToInstance(ProductVariantDTO, data, {
|
||||
excludeExtraneousValues: true,
|
||||
enableImplicitConversion: true,
|
||||
});
|
||||
|
||||
return productVariantDTO;
|
||||
}
|
||||
}
|
||||
|
||||
// @Transform((value) => new Types.ObjectId(value.obj._id.toString()))
|
||||
// _id: Types.ObjectId;
|
||||
|
||||
//#################################
|
||||
//#################################
|
||||
export class ProductDTO {
|
||||
@Expose()
|
||||
_id: number;
|
||||
|
||||
@Expose()
|
||||
url: string;
|
||||
|
||||
@Expose()
|
||||
title_fa: string;
|
||||
|
||||
@Expose()
|
||||
title_en: string;
|
||||
|
||||
@Expose()
|
||||
seoTitle: string;
|
||||
|
||||
@Expose()
|
||||
seoDescription: string;
|
||||
|
||||
model: string;
|
||||
|
||||
@Expose()
|
||||
source: string;
|
||||
|
||||
@Expose()
|
||||
description: string;
|
||||
|
||||
@Expose()
|
||||
metaDescription: string;
|
||||
|
||||
@Expose()
|
||||
tags: string[];
|
||||
|
||||
@Expose()
|
||||
advantages: string[];
|
||||
|
||||
@Expose()
|
||||
disAdvantages: string[];
|
||||
|
||||
@Expose()
|
||||
@Expose()
|
||||
@Type(() => ImagesUrlDTO)
|
||||
imagesUrl: ImagesUrlDTO;
|
||||
|
||||
@Expose()
|
||||
isFake: string;
|
||||
|
||||
@Expose()
|
||||
isWished: boolean;
|
||||
|
||||
@Expose()
|
||||
voice: string;
|
||||
|
||||
@Expose()
|
||||
@Type(() => SpecificationsDTO)
|
||||
specifications: SpecificationsDTO[];
|
||||
|
||||
@Expose()
|
||||
@Type(() => BrandDTO)
|
||||
brand: BrandDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => CategoryTreeDTO)
|
||||
category: CategoryTreeDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductDetailVariantDTO)
|
||||
default_variant: ProductDetailVariantDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductDetailVariantDTO)
|
||||
variants: ProductDetailVariantDTO[];
|
||||
|
||||
// @Expose()
|
||||
// categoryPath: string;
|
||||
|
||||
public static transformProduct(data: IProduct): ProductDTO {
|
||||
const productDTO = plainToInstance(ProductDTO, data, {
|
||||
excludeExtraneousValues: true,
|
||||
enableImplicitConversion: true,
|
||||
});
|
||||
|
||||
return productDTO;
|
||||
}
|
||||
}
|
||||
|
||||
export class RejectCommentDTO {
|
||||
@Expose()
|
||||
@IsString()
|
||||
@ApiProperty({ type: "string", description: "reject reason", example: "reject for this reason" })
|
||||
adminComments: string;
|
||||
}
|
||||
|
||||
export class IncredibleOffersDTO {
|
||||
@Expose()
|
||||
@Type(() => ProductDTO)
|
||||
product: ProductDTO;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ProductVariantDTO)
|
||||
variant: ProductVariantDTO;
|
||||
|
||||
public static transformIncredibleOffers(data: IncredibleOffers): IncredibleOffersDTO {
|
||||
const incredibleOffersDTO = plainToInstance(IncredibleOffersDTO, data, {
|
||||
excludeExtraneousValues: true,
|
||||
enableImplicitConversion: true,
|
||||
});
|
||||
|
||||
return incredibleOffersDTO;
|
||||
}
|
||||
}
|
||||
|
||||
export class ProductListDTO {
|
||||
@Expose()
|
||||
_id: number;
|
||||
|
||||
@Expose()
|
||||
title_fa: string;
|
||||
|
||||
@Expose()
|
||||
title_en: string;
|
||||
|
||||
@Expose()
|
||||
seoTitle: string;
|
||||
|
||||
@Expose()
|
||||
seoDescription: string;
|
||||
}
|
||||
Reference in New Issue
Block a user