added entities for space product item

This commit is contained in:
hannathkadher
2024-12-11 15:27:06 +04:00
parent 37d016ea43
commit 88a4b26919
12 changed files with 80 additions and 24 deletions

View File

@ -19,14 +19,13 @@ export class SpaceProductItemModelService {
spaceModel: SpaceModelEntity,
queryRunner: QueryRunner,
) {
await this.validateTags(itemModelDtos, spaceModel, queryRunner);
await this.validateTags(itemModelDtos, queryRunner, spaceModel);
try {
const productItems = itemModelDtos.map((dto) =>
queryRunner.manager.create(this.spaceProductItemRepository.target, {
tag: dto.tag,
spaceProductModel,
spaceModel,
}),
);
@ -46,8 +45,8 @@ export class SpaceProductItemModelService {
private async validateTags(
itemModelDtos: CreateSpaceProductItemModelDto[],
spaceModel: SpaceModelEntity,
queryRunner: QueryRunner,
spaceModel: SpaceModelEntity,
) {
const incomingTags = itemModelDtos.map((item) => item.tag);
@ -64,7 +63,7 @@ export class SpaceProductItemModelService {
const existingTags = await queryRunner.manager.find(
this.spaceProductItemRepository.target,
{
where: { spaceModel },
where: { spaceProductModel: { spaceModel } },
select: ['tag'],
},
);