added controller

This commit is contained in:
hannathkadher
2024-10-31 10:14:59 +04:00
parent f1c07360cb
commit f28fa627ed
5 changed files with 23 additions and 31 deletions

View File

@ -2,7 +2,6 @@ import { IsDate, IsOptional } from 'class-validator';
import { IsPageRequestParam } from '../validators/is-page-request-param.validator'; import { IsPageRequestParam } from '../validators/is-page-request-param.validator';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { IsSizeRequestParam } from '../validators/is-size-request-param.validator'; import { IsSizeRequestParam } from '../validators/is-size-request-param.validator';
import { IsSortParam } from '../validators/is-sort-param.validator';
import { Transform } from 'class-transformer'; import { Transform } from 'class-transformer';
import { parseToDate } from '../util/parseToDate'; import { parseToDate } from '../util/parseToDate';
@ -29,18 +28,6 @@ export class PaginationRequestGetListDto {
}) })
size?: number; size?: number;
@IsOptional()
@IsSortParam({
message:
'Incorrect sorting condition format. Should be like this format propertyId:asc,createdDate:desc',
})
@ApiProperty({
name: 'sort',
required: false,
description: 'Sort condition',
})
sort?: string;
@IsOptional() @IsOptional()
@ApiProperty({ @ApiProperty({
name: 'name', name: 'name',
@ -49,14 +36,6 @@ export class PaginationRequestGetListDto {
}) })
name?: string; name?: string;
@IsOptional()
@ApiProperty({
name: 'include',
required: false,
description: 'Fields to include',
})
include?: string;
@ApiProperty({ @ApiProperty({
name: 'from', name: 'from',
required: false, required: false,

View File

@ -6,7 +6,6 @@ export function buildTypeORMWhereClause({ where }) {
// Remove extra nesting if `where` is wrapped within an additional `where` property // Remove extra nesting if `where` is wrapped within an additional `where` property
const condition = where.where ? where.where : where; const condition = where.where ? where.where : where;
console.log(condition);
const convertToNestedObject = (condition: any): any => { const convertToNestedObject = (condition: any): any => {
const result = {}; const result = {};
for (const [key, value] of Object.entries(condition)) { for (const [key, value] of Object.entries(condition)) {

View File

@ -138,6 +138,7 @@ export class DeviceController {
async getAllDevices() { async getAllDevices() {
return await this.deviceService.getAllDevices(); return await this.deviceService.getAllDevices();
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('report-logs/:deviceUuid') @Get('report-logs/:deviceUuid')

View File

@ -1,6 +1,6 @@
export interface GetDeviceDetailsInterface { export interface GetDeviceDetailsInterface {
activeTime: number; activeTime: number;
assetId: string; assetId?: string;
category: string; category: string;
categoryName: string; categoryName: string;
createTime: number; createTime: number;
@ -13,6 +13,7 @@ export interface GetDeviceDetailsInterface {
lon: string; lon: string;
model: string; model: string;
name: string; name: string;
battery?: number;
nodeId: string; nodeId: string;
online: boolean; online: boolean;
productId?: string; productId?: string;
@ -23,6 +24,18 @@ export interface GetDeviceDetailsInterface {
uuid: string; uuid: string;
productType: string; productType: string;
productUuid: string; productUuid: string;
spaces?: SpaceInterface[];
community?: CommunityInterface;
}
export interface SpaceInterface {
uuid: string;
spaceName: string;
}
export interface CommunityInterface {
uuid: string;
name: string;
} }
export interface addDeviceInRoomInterface { export interface addDeviceInRoomInterface {

View File

@ -614,12 +614,12 @@ export class DeviceService {
} }
} }
async getDevicesInstructionStatus(deviceUuid: string) { async getDevicesInstructionStatus(deviceUuid: string) {
const deviceDetails = await this.getDeviceByDeviceUuid(deviceUuid);
if (!deviceDetails) {
throw new NotFoundException('Device Not Found');
}
try { try {
const deviceDetails = await this.getDeviceByDeviceUuid(deviceUuid);
if (!deviceDetails) {
throw new NotFoundException('Device Not Found');
}
const deviceStatus = await this.getDevicesInstructionStatusTuya( const deviceStatus = await this.getDevicesInstructionStatusTuya(
deviceDetails.deviceTuyaUuid, deviceDetails.deviceTuyaUuid,
); );
@ -902,12 +902,12 @@ export class DeviceService {
name: device.spaceDevice.community.name, name: device.spaceDevice.community.name,
}, },
// permissionType: device.permission[0].permissionType.type, // permissionType: device.permission[0].permissionType.type,
/* ...(await this.getDeviceDetailsByDeviceIdTuya( ...(await this.getDeviceDetailsByDeviceIdTuya(
device.deviceTuyaUuid, device.deviceTuyaUuid,
)),*/ )),
uuid: device.uuid, uuid: device.uuid,
...(battery && { battery }), ...(battery && { battery }),
}; } as GetDeviceDetailsInterface;
}), }),
); );