mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 16:27:55 +00:00
update in tag service
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { AddSubspaceDto } from './subspace';
|
||||
import { CreateTagDto } from './tag';
|
||||
|
||||
export class AddSpaceDto {
|
||||
@ApiProperty({
|
||||
@@ -77,6 +78,15 @@ export class AddSpaceDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AddSubspaceDto)
|
||||
subspaces?: AddSubspaceDto[];
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of tags associated with the space model',
|
||||
type: [CreateTagDto],
|
||||
})
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => CreateTagDto)
|
||||
tags?: CreateTagDto[];
|
||||
}
|
||||
|
||||
export class AddUserSpaceDto {
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from './user-space.param';
|
||||
export * from './subspace';
|
||||
export * from './project.param.dto';
|
||||
export * from './update.space.dto';
|
||||
export * from './tag';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsArray, IsNotEmpty, IsString, ValidateNested } from 'class-validator';
|
||||
import { CreateTagDto } from '../tag';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class AddSubspaceDto {
|
||||
@ApiProperty({
|
||||
@@ -9,4 +11,13 @@ export class AddSubspaceDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
subspaceName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of tags associated with the subspace',
|
||||
type: [CreateTagDto],
|
||||
})
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => CreateTagDto)
|
||||
tags?: CreateTagDto[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class DeleteSubspaceDto {
|
||||
@ApiProperty({
|
||||
description: 'Uuid of the subspace model need to be deleted',
|
||||
example: '982fc3a3-64dc-4afb-a5b5-65ee8fef0424',
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
subspaceUuid: string;
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
export * from './add.subspace.dto';
|
||||
export * from './get.subspace.param';
|
||||
export * from './add.subspace-device.param';
|
||||
export * from './update.subspace.dto';
|
||||
export * from './delete.subspace.dto';
|
||||
export * from './modify.subspace.dto';
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { ModifyAction } from '@app/common/constants/modify-action.enum';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsEnum,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsArray,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { ModifyTagDto } from '../tag/modify-tag.dto';
|
||||
|
||||
export class ModifySubspaceDto {
|
||||
@ApiProperty({
|
||||
description: 'Action to perform: add, update, or delete',
|
||||
example: ModifyAction.ADD,
|
||||
})
|
||||
@IsEnum(ModifyAction)
|
||||
action: ModifyAction;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'UUID of the subspace (required for update/delete)',
|
||||
example: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
uuid?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Name of the subspace (required for add/update)',
|
||||
example: 'Living Room',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
subspaceName?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'List of tag modifications (add/update/delete) for the subspace',
|
||||
type: [ModifyTagDto],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ModifyTagDto)
|
||||
tags?: ModifyTagDto[];
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UpdateSubspaceDto {
|
||||
@ApiProperty({
|
||||
description: 'Name of the subspace',
|
||||
example: 'Living Room',
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
subspaceName?: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
subspaceUuid: string;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class CreateTagDto {
|
||||
@ApiProperty({
|
||||
description: 'Tag associated with the space or subspace',
|
||||
example: 'Temperature Control',
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
tag: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID of the product associated with the tag',
|
||||
example: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
productUuid: string;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './create-tag-dto';
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ModifyAction } from '@app/common/constants/modify-action.enum';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class ModifyTagDto {
|
||||
@ApiProperty({
|
||||
description: 'Action to perform: add, update, or delete',
|
||||
example: ModifyAction.ADD,
|
||||
})
|
||||
@IsEnum(ModifyAction)
|
||||
action: ModifyAction;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'UUID of the tag (required for update/delete)',
|
||||
example: '123e4567-e89b-12d3-a456-426614174000',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
uuid?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Name of the tag (required for add/update)',
|
||||
example: 'Temperature Sensor',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
tag?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'UUID of the product associated with the tag (required for add)',
|
||||
example: 'c789a91e-549a-4753-9006-02f89e8170e0',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
productUuid?: string;
|
||||
}
|
||||
@@ -1,4 +1,59 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { AddSpaceDto } from './add.space.dto';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsArray,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { ModifySubspaceDto } from './subspace';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ModifyTagDto } from './tag/modify-tag.dto';
|
||||
|
||||
export class UpdateSpaceDto extends PartialType(AddSpaceDto) {}
|
||||
export class UpdateSpaceDto {
|
||||
@ApiProperty({
|
||||
description: 'Updated name of the space ',
|
||||
example: 'New Space Name',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
spaceName?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Icon identifier for the space',
|
||||
example: 'assets/location',
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
public icon?: string;
|
||||
|
||||
@ApiProperty({ description: 'X position on canvas', example: 120 })
|
||||
@IsNumber()
|
||||
x: number;
|
||||
|
||||
@ApiProperty({ description: 'Y position on canvas', example: 200 })
|
||||
@IsNumber()
|
||||
y: number;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'List of subspace modifications (add/update/delete)',
|
||||
type: [ModifySubspaceDto],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ModifySubspaceDto)
|
||||
subspaceModels?: ModifySubspaceDto[];
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'List of tag modifications (add/update/delete) for the space model',
|
||||
type: [ModifyTagDto],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ModifyTagDto)
|
||||
tags?: ModifyTagDto[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user