mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
Add building and get building DTOs
This commit is contained in:
23
src/building/dtos/add.building.dto.ts
Normal file
23
src/building/dtos/add.building.dto.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
|
export class AddBuildingDto {
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'buildingName',
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public buildingName: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'communityUuid',
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public communityUuid: string;
|
||||||
|
constructor(dto: Partial<AddBuildingDto>) {
|
||||||
|
Object.assign(this, dto);
|
||||||
|
}
|
||||||
|
}
|
51
src/building/dtos/get.building.dto.ts
Normal file
51
src/building/dtos/get.building.dto.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
|
import {
|
||||||
|
IsBoolean,
|
||||||
|
IsInt,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
Min,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
|
export class GetBuildingDto {
|
||||||
|
@ApiProperty({
|
||||||
|
description: 'buildingUuid',
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public buildingUuid: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetBuildingChildDto {
|
||||||
|
@ApiProperty({ example: 1, description: 'Page number', required: true })
|
||||||
|
@IsInt({ message: 'Page must be a number' })
|
||||||
|
@Min(1, { message: 'Page must not be less than 1' })
|
||||||
|
@IsNotEmpty()
|
||||||
|
public page: number;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: 10,
|
||||||
|
description: 'Number of items per page',
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsInt({ message: 'Page size must be a number' })
|
||||||
|
@Min(1, { message: 'Page size must not be less than 1' })
|
||||||
|
@IsNotEmpty()
|
||||||
|
public pageSize: number;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: true,
|
||||||
|
description: 'Flag to determine whether to fetch full hierarchy',
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
@IsBoolean()
|
||||||
|
@Transform((value) => {
|
||||||
|
return value.obj.includeSubSpaces === 'true';
|
||||||
|
})
|
||||||
|
public includeSubSpaces: boolean = false;
|
||||||
|
}
|
1
src/building/dtos/index.ts
Normal file
1
src/building/dtos/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './add.building.dto';
|
Reference in New Issue
Block a user