mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 11:44:53 +00:00
created abstract class
This commit is contained in:
@ -6,12 +6,15 @@ import { In, QueryRunner } from 'typeorm';
|
|||||||
import { ProductAssignmentDto } from '../../dtos';
|
import { ProductAssignmentDto } from '../../dtos';
|
||||||
import { SpaceProductItemService } from '../space-product-items';
|
import { SpaceProductItemService } from '../space-product-items';
|
||||||
import { SpaceModelEntity } from '@app/common/modules/space-model';
|
import { SpaceModelEntity } from '@app/common/modules/space-model';
|
||||||
|
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||||
|
import { ProductService } from 'src/product/services';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpaceProductService {
|
export class SpaceProductService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly productRepository: ProductRepository,
|
private readonly productRepository: ProductRepository,
|
||||||
private readonly spaceProductItemService: SpaceProductItemService,
|
private readonly spaceProductItemService: SpaceProductItemService,
|
||||||
|
private readonly productService: ProductService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async createFromModel(
|
async createFromModel(
|
||||||
@ -176,6 +179,7 @@ export class SpaceProductService {
|
|||||||
|
|
||||||
for (const uniqueSpaceProduct of uniqueSpaceProducts) {
|
for (const uniqueSpaceProduct of uniqueSpaceProducts) {
|
||||||
const product = productEntities.get(uniqueSpaceProduct.productId);
|
const product = productEntities.get(uniqueSpaceProduct.productId);
|
||||||
|
await this.getProduct(uniqueSpaceProduct.productId);
|
||||||
this.validateProductCount(uniqueSpaceProduct);
|
this.validateProductCount(uniqueSpaceProduct);
|
||||||
|
|
||||||
newProducts.push(
|
newProducts.push(
|
||||||
@ -214,4 +218,9 @@ export class SpaceProductService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getProduct(productId: string): Promise<ProductEntity> {
|
||||||
|
const product = await this.productService.findOne(productId);
|
||||||
|
return product.data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user