mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 12:44:54 +00:00
Merge branch 'feat/add-product-space' into feat/add-space-position
This commit is contained in:
@ -12,6 +12,7 @@ import { CommunityRepository } from '@app/common/modules/community/repositories'
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { generateRandomString } from '@app/common/helper/randomString';
|
||||
import { SpaceLinkService } from './space-link';
|
||||
import { SpaceProductService } from './space-products';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceService {
|
||||
@ -19,13 +20,14 @@ export class SpaceService {
|
||||
private readonly spaceRepository: SpaceRepository,
|
||||
private readonly communityRepository: CommunityRepository,
|
||||
private readonly spaceLinkService: SpaceLinkService,
|
||||
private readonly spaceProductService: SpaceProductService,
|
||||
) {}
|
||||
|
||||
async createSpace(
|
||||
addSpaceDto: AddSpaceDto,
|
||||
communityId: string,
|
||||
): Promise<BaseResponseDto> {
|
||||
const { parentUuid, direction } = addSpaceDto;
|
||||
const { parentUuid, direction, products } = addSpaceDto;
|
||||
|
||||
const community = await this.validateCommunity(communityId);
|
||||
|
||||
@ -47,6 +49,13 @@ export class SpaceService {
|
||||
);
|
||||
}
|
||||
|
||||
if (products && products.length > 0) {
|
||||
await this.spaceProductService.assignProductsToSpace(
|
||||
newSpace,
|
||||
products,
|
||||
);
|
||||
}
|
||||
|
||||
return new SuccessResponseDto({
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: newSpace,
|
||||
|
||||
Reference in New Issue
Block a user