mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 07:24:55 +00:00
fix issues
This commit is contained in:
@ -13,8 +13,7 @@ import {
|
||||
SubspaceModelProductAllocationRepoitory,
|
||||
TagModel,
|
||||
} from '@app/common/modules/space-model';
|
||||
import { DataSource, In, QueryRunner } from 'typeorm';
|
||||
import { SubSpaceService } from 'src/space/services';
|
||||
import { In, QueryRunner } from 'typeorm';
|
||||
import { TagService } from 'src/space/services/tag';
|
||||
import {
|
||||
ISingleSubspaceModel,
|
||||
@ -30,8 +29,6 @@ export class PropogateUpdateSpaceModelHandler
|
||||
constructor(
|
||||
private readonly spaceRepository: SpaceRepository,
|
||||
private readonly subspaceRepository: SubspaceRepository,
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly subSpaceService: SubSpaceService,
|
||||
private readonly tagService: TagService,
|
||||
private readonly subspaceModelProductRepository: SubspaceModelProductAllocationRepoitory,
|
||||
private readonly subspaceProductRepository: SubspaceProductAllocationRepository,
|
||||
@ -111,7 +108,9 @@ export class PropogateUpdateSpaceModelHandler
|
||||
],
|
||||
});
|
||||
|
||||
if (!subspaces.length) return;
|
||||
if (!subspaces.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const allocationUuidsToRemove = subspaces.flatMap((subspace) =>
|
||||
subspace.productAllocations.map((allocation) => allocation.uuid),
|
||||
@ -127,7 +126,10 @@ export class PropogateUpdateSpaceModelHandler
|
||||
);
|
||||
|
||||
const relocatedAllocations = subspaceModel.relocatedAllocations || [];
|
||||
if (!relocatedAllocations.length) return;
|
||||
|
||||
if (!relocatedAllocations.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const space of spaces) {
|
||||
for (const { allocation, tags = [] } of relocatedAllocations) {
|
||||
|
||||
@ -440,11 +440,12 @@ export class SpaceModelService {
|
||||
queryRunner?: QueryRunner, // Make queryRunner optional
|
||||
): Promise<void> {
|
||||
try {
|
||||
space.spaceModel = spaceModel;
|
||||
if (queryRunner) {
|
||||
await queryRunner.manager.save(SpaceEntity, space);
|
||||
await queryRunner.manager.update(SpaceEntity, space.uuid, {
|
||||
spaceModel,
|
||||
});
|
||||
} else {
|
||||
await this.spaceRepository.save(space);
|
||||
await this.spaceRepository.update(space.uuid, { spaceModel });
|
||||
}
|
||||
const spaceProductAllocations = spaceModel.productAllocations.map(
|
||||
(modelAllocation) =>
|
||||
|
||||
@ -281,7 +281,7 @@ export class SubspaceModelProductAllocationService {
|
||||
queryRunner: QueryRunner,
|
||||
spaceModel: SpaceModelEntity,
|
||||
spaceTagUpdateDtos?: ModifyTagModelDto[],
|
||||
) {
|
||||
): Promise<IUpdatedAllocations[]> {
|
||||
const spaceAllocationToExclude: SpaceModelProductAllocationEntity[] = [];
|
||||
const updatedAllocations: IUpdatedAllocations[] = [];
|
||||
|
||||
|
||||
@ -145,13 +145,14 @@ export class SubSpaceModelService {
|
||||
);
|
||||
const combineModels = [...createdSubspaces, ...updatedSubspaces];
|
||||
|
||||
await this.productAllocationService.updateAllocations(
|
||||
combineModels,
|
||||
projectUuid,
|
||||
queryRunner,
|
||||
spaceModel,
|
||||
spaceTagUpdateDtos,
|
||||
);
|
||||
const updatedAllocations =
|
||||
await this.productAllocationService.updateAllocations(
|
||||
combineModels,
|
||||
projectUuid,
|
||||
queryRunner,
|
||||
spaceModel,
|
||||
spaceTagUpdateDtos,
|
||||
);
|
||||
|
||||
const deletedSubspaces = await this.deleteSubspaceModels(
|
||||
deleteDtos,
|
||||
|
||||
Reference in New Issue
Block a user