mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 21:37:54 +00:00
Merge pull request #477 from SyncrowIOT/task/implement-duplicate-space-apo
SP-1822: implement duplicate space API
This commit is contained in:
@@ -223,6 +223,10 @@ export class ControllerRoute {
|
||||
public static readonly CREATE_SPACE_DESCRIPTION =
|
||||
'This endpoint allows you to create a space in a specified community. Optionally, you can specify a parent space to nest the new space under it.';
|
||||
|
||||
public static readonly DUPLICATE_SPACE_SUMMARY = 'Duplicate a space';
|
||||
public static readonly DUPLICATE_SPACE_DESCRIPTION =
|
||||
'This endpoint allows you to create a copy of an existing space in a specified community.';
|
||||
|
||||
public static readonly LIST_SPACE_SUMMARY = 'List spaces in community';
|
||||
public static readonly LIST_SPACE_DESCRIPTION =
|
||||
'List spaces in specified community by community id';
|
||||
|
||||
@@ -22,6 +22,11 @@ export class SpaceProductAllocationEntity extends AbstractEntity<SpaceProductAll
|
||||
})
|
||||
public space: SpaceEntity;
|
||||
|
||||
@Column({
|
||||
name: 'space_uuid',
|
||||
})
|
||||
public spaceUuid: string;
|
||||
|
||||
@ManyToOne(() => SpaceModelProductAllocationEntity, {
|
||||
nullable: true,
|
||||
onDelete: 'SET NULL',
|
||||
@@ -31,9 +36,19 @@ export class SpaceProductAllocationEntity extends AbstractEntity<SpaceProductAll
|
||||
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
|
||||
public product: ProductEntity;
|
||||
|
||||
@Column({
|
||||
name: 'product_uuid',
|
||||
})
|
||||
public productUuid: string;
|
||||
|
||||
@ManyToOne(() => NewTagEntity, { nullable: true, onDelete: 'CASCADE' })
|
||||
public tag: NewTagEntity;
|
||||
|
||||
@Column({
|
||||
name: 'tag_uuid',
|
||||
})
|
||||
public tagUuid: string;
|
||||
|
||||
constructor(partial: Partial<SpaceProductAllocationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { AqiSpaceDailyPollutantStatsEntity } from '../../aqi/entities';
|
||||
import { BookableSpaceEntity } from '../../booking/entities/bookable-space.entity';
|
||||
import { BookingEntity } from '../../booking/entities/booking.entity';
|
||||
import { CommunityEntity } from '../../community/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { InviteUserSpaceEntity } from '../../Invite-user/entities';
|
||||
@@ -20,7 +21,6 @@ import { UserSpaceEntity } from '../../user/entities';
|
||||
import { SpaceDto } from '../dtos';
|
||||
import { SpaceProductAllocationEntity } from './space-product-allocation.entity';
|
||||
import { SubspaceEntity } from './subspace/subspace.entity';
|
||||
import { BookingEntity } from '../../booking/entities/booking.entity';
|
||||
|
||||
@Entity({ name: 'space' })
|
||||
export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
@@ -47,12 +47,26 @@ export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
@JoinColumn({ name: 'community_id' })
|
||||
community: CommunityEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.children, { nullable: true })
|
||||
@Column({
|
||||
name: 'community_id',
|
||||
})
|
||||
communityId: string;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.children, {
|
||||
nullable: true,
|
||||
})
|
||||
parent: SpaceEntity;
|
||||
|
||||
@Column({
|
||||
name: 'parent_uuid',
|
||||
nullable: true,
|
||||
})
|
||||
public parentUuid: string;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.parent, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
cascade: true,
|
||||
})
|
||||
children: SpaceEntity[];
|
||||
|
||||
@@ -73,6 +87,7 @@ export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
|
||||
@OneToMany(() => SubspaceEntity, (subspace) => subspace.space, {
|
||||
nullable: true,
|
||||
cascade: true,
|
||||
})
|
||||
subspaces?: SubspaceEntity[];
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ export class SubspaceProductAllocationEntity extends AbstractEntity<SubspaceProd
|
||||
})
|
||||
public subspace: SubspaceEntity;
|
||||
|
||||
@Column({
|
||||
name: 'subspace_uuid',
|
||||
})
|
||||
public subspaceUuid: string;
|
||||
|
||||
@ManyToOne(() => SubspaceModelProductAllocationEntity, {
|
||||
nullable: true,
|
||||
onDelete: 'SET NULL',
|
||||
@@ -31,9 +36,19 @@ export class SubspaceProductAllocationEntity extends AbstractEntity<SubspaceProd
|
||||
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
|
||||
public product: ProductEntity;
|
||||
|
||||
@Column({
|
||||
name: 'product_uuid',
|
||||
})
|
||||
public productUuid: string;
|
||||
|
||||
@ManyToOne(() => NewTagEntity, { nullable: true, onDelete: 'CASCADE' })
|
||||
public tag: NewTagEntity;
|
||||
|
||||
@Column({
|
||||
name: 'tag_uuid',
|
||||
})
|
||||
public tagUuid: string;
|
||||
|
||||
constructor(partial: Partial<SubspaceProductAllocationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
||||
@@ -26,6 +26,11 @@ export class SubspaceEntity extends AbstractEntity<SubspaceDto> {
|
||||
@JoinColumn({ name: 'space_uuid' })
|
||||
space: SpaceEntity;
|
||||
|
||||
@Column({
|
||||
name: 'space_uuid',
|
||||
})
|
||||
public spaceUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
|
||||
Reference in New Issue
Block a user