mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 10:44:55 +00:00
create orphan community and space for project
This commit is contained in:
@ -10,10 +10,15 @@ import {
|
||||
} from '@app/common/models/typeOrmCustom.model';
|
||||
import { ProjectDto } from '@app/common/modules/project/dtos';
|
||||
import { PageResponse } from '@app/common/dto/pagination.response.dto';
|
||||
import { CommandBus } from '@nestjs/cqrs';
|
||||
import { CreateOrphanSpaceCommand } from '../command/create-orphan-space-command';
|
||||
|
||||
@Injectable()
|
||||
export class ProjectService {
|
||||
constructor(private readonly projectRepository: ProjectRepository) {}
|
||||
constructor(
|
||||
private readonly projectRepository: ProjectRepository,
|
||||
private commandBus: CommandBus,
|
||||
) {}
|
||||
|
||||
async createProject(
|
||||
createProjectDto: CreateProjectDto,
|
||||
@ -33,6 +38,8 @@ export class ProjectService {
|
||||
const newProject = this.projectRepository.create(createProjectDto);
|
||||
const savedProject = await this.projectRepository.save(newProject);
|
||||
|
||||
await this.commandBus.execute(new CreateOrphanSpaceCommand(savedProject));
|
||||
|
||||
return new SuccessResponseDto({
|
||||
message: `Project with ID ${savedProject.uuid} successfully created`,
|
||||
data: savedProject,
|
||||
@ -44,7 +51,7 @@ export class ProjectService {
|
||||
}
|
||||
|
||||
throw new HttpException(
|
||||
'An error occurred while creating the project. Please try again later.',
|
||||
`An error occurred while creating the project. Please try again later. ${error}`,
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user