@@ -13,25 +13,29 @@ export enum ProductStatus {
13
13
UnderTheOrder = 1
14
14
}
15
15
16
+ export type CategoryUnion = Category | CategoryElectronicsDto | CategoryMotorsDto ;
17
+ export type ICategoryUnion = ICategory | ICategoryElectronicsDto | ICategoryMotorsDto ;
18
+
19
+ export interface ICategory {
20
+ name : $types . TypeOrUndefinedNullable < string > ;
21
+ type : $types . TypeOrUndefined < string > ;
22
+ }
23
+
16
24
interface ICategoryElectronicsDtoBaseInterface {
17
25
syntheticTest : $types . TypeOrUndefinedNullable < number > ;
18
26
}
19
27
28
+ export type ICategoryElectronicsDto = ICategoryElectronicsDtoBaseInterface & ICategory ;
29
+
20
30
interface ICategoryMotorsDtoBaseInterface {
21
31
volume : $types . TypeOrUndefinedNullable < number > ;
22
32
}
23
33
24
- export interface ICategory {
25
- name : $types . TypeOrUndefinedNullable < string > ;
26
- type : $types . TypeOrUndefined < string > ;
27
- }
28
-
29
- export type ICategoryElectronicsDto = ICategoryElectronicsDtoBaseInterface & ICategory ;
30
34
export type ICategoryMotorsDto = ICategoryMotorsDtoBaseInterface & ICategory ;
31
35
32
36
export interface IProduct {
33
- categories : $types . TypeOrUndefinedNullable < ICategory [ ] > ;
34
- category : $types . TypeOrUndefinedNullable < ICategory > ;
37
+ categories : $types . TypeOrUndefined < ICategoryUnion [ ] > ;
38
+ category : $types . TypeOrUndefined < ICategoryUnion > ;
35
39
colors : $types . TypeOrUndefined < string [ ] > ;
36
40
expireDate : $types . TypeOrUndefined < string > ;
37
41
externalId : $types . TypeOrUndefinedNullable < string > ;
@@ -45,9 +49,6 @@ export interface IProductIdentityDTO {
45
49
id : $types . TypeOrUndefined < string > ;
46
50
}
47
51
48
- export type CategoryUnion = Category | CategoryElectronicsDto | CategoryMotorsDto ;
49
- export type ICategoryUnion = ICategory | ICategoryElectronicsDto | ICategoryMotorsDto ;
50
-
51
52
export class CategoryUnionClass {
52
53
public static fromDTO ( dto : ICategoryUnion ) : CategoryUnion {
53
54
if ( this . isCategoryElectronicsDto ( dto ) ) {
@@ -166,8 +167,8 @@ export class CategoryMotorsDto {
166
167
}
167
168
168
169
export class Product {
169
- public categories : CategoryUnionClass [ ] = [ ] ;
170
- public category : $types . TypeOrUndefinedNullable < CategoryUnionClass > = undefined ;
170
+ public categories : CategoryUnion [ ] = [ ] ;
171
+ public category : $types . TypeOrUndefined < CategoryUnion > = undefined ;
171
172
public colors : string [ ] = [ ] ;
172
173
public expireDate : $types . TypeOrUndefined < Date > = undefined ;
173
174
public externalId : $types . TypeOrUndefinedNullable < Guid > = undefined ;
@@ -179,8 +180,8 @@ export class Product {
179
180
180
181
public static toDTO ( model : Partial < Product > ) : IProduct {
181
182
return {
182
- categories : model . categories ? model . categories . map ( x => Category . toDTO ( x ) ) : undefined ,
183
- category : model . category ? Category . toDTO ( model . category ) : undefined ,
183
+ categories : model . categories ? model . categories . map ( x => CategoryUnionClass . toDTO ( x ) ) : undefined ,
184
+ category : model . category ? CategoryUnionClass . toDTO ( model . category ) : undefined ,
184
185
colors : model . colors ,
185
186
expireDate : toDateOut ( model . expireDate ) ,
186
187
externalId : model . externalId ? model . externalId . toString ( ) : null ,
@@ -193,8 +194,8 @@ export class Product {
193
194
194
195
public static fromDTO ( dto : IProduct ) : Product {
195
196
const model = new Product ( ) ;
196
- model . categories = dto . categories ? dto . categories . map ( x => Category . fromDTO ( x ) ) : [ ] ;
197
- model . category = dto . category ? Category . fromDTO ( dto . category ) : undefined ;
197
+ model . categories = dto . categories ? dto . categories . map ( x => CategoryUnionClass . fromDTO ( x ) ) : [ ] ;
198
+ model . category = dto . category ? CategoryUnionClass . fromDTO ( dto . category ) : undefined ;
198
199
model . colors = dto . colors ? dto . colors : [ ] ;
199
200
model . expireDate = toDateIn ( dto . expireDate ) ;
200
201
model . externalId = dto . externalId ? new Guid ( dto . externalId ) : null ;
0 commit comments