mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Merge branch 'create-orphan-space-for-project' of https://github.com/SyncrowIOT/backend into feat/list-space-model
This commit is contained in:
@ -3,10 +3,7 @@ import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
|||||||
import { SubspaceEntity } from './subspace.entity';
|
import { SubspaceEntity } from './subspace.entity';
|
||||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||||
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
||||||
import {
|
import { SubspaceProductModelEntity } from '@app/common/modules/space-model';
|
||||||
SubspaceProductItemModelEntity,
|
|
||||||
SubspaceProductModelEntity,
|
|
||||||
} from '@app/common/modules/space-model';
|
|
||||||
import { SpaceProductModelDto } from '../../dtos';
|
import { SpaceProductModelDto } from '../../dtos';
|
||||||
|
|
||||||
@Entity({ name: 'subspace-product' })
|
@Entity({ name: 'subspace-product' })
|
||||||
|
@ -117,7 +117,7 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
|||||||
public visitorPasswords: VisitorPasswordEntity[];
|
public visitorPasswords: VisitorPasswordEntity[];
|
||||||
|
|
||||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.users, {
|
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.users, {
|
||||||
nullable: true,
|
nullable: false,
|
||||||
})
|
})
|
||||||
public roleType: RoleTypeEntity;
|
public roleType: RoleTypeEntity;
|
||||||
@OneToOne(() => InviteUserEntity, (inviteUser) => inviteUser.user, {
|
@OneToOne(() => InviteUserEntity, (inviteUser) => inviteUser.user, {
|
||||||
|
@ -23,13 +23,15 @@ export class CreateOrphanSpaceHandler
|
|||||||
async execute(command: CreateOrphanSpaceCommand): Promise<void> {
|
async execute(command: CreateOrphanSpaceCommand): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { project } = command;
|
const { project } = command;
|
||||||
|
const orphanCommunityName = `${ORPHAN_COMMUNITY_NAME}-${project.name}`;
|
||||||
|
|
||||||
let orphanCommunity = await this.communityRepository.findOne({
|
let orphanCommunity = await this.communityRepository.findOne({
|
||||||
where: { name: ORPHAN_COMMUNITY_NAME, project },
|
where: { name: orphanCommunityName, project },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!orphanCommunity) {
|
if (!orphanCommunity) {
|
||||||
orphanCommunity = this.communityRepository.create({
|
orphanCommunity = this.communityRepository.create({
|
||||||
name: ORPHAN_COMMUNITY_NAME,
|
name: orphanCommunityName,
|
||||||
description: ORPHAN_COMMUNITY_DESCRIPTION,
|
description: ORPHAN_COMMUNITY_DESCRIPTION,
|
||||||
project,
|
project,
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user