Merge branch 'feat/add-product-space' into feat/add-space-position

This commit is contained in:
hannathkadher
2024-11-20 21:46:33 +04:00
38 changed files with 821 additions and 23 deletions

View File

@ -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,