edit category from param to query

This commit is contained in:
faris Aljohari
2024-09-15 18:09:34 +03:00
parent d962d4a7b3
commit 5b6dcc1440
4 changed files with 20 additions and 6 deletions

View File

@ -10,9 +10,14 @@ import {
UseGuards,
Put,
Delete,
Query,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { AddScheduleDto, EnableScheduleDto } from '../dtos/add.schedule.dto';
import {
AddScheduleDto,
EnableScheduleDto,
GetScheduleDeviceDto,
} from '../dtos/schedule.dto';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
@ -51,15 +56,15 @@ export class ScheduleController {
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':deviceUuid/category/:category')
@Get(':deviceUuid')
async getDeviceScheduleByCategory(
@Param('deviceUuid') deviceUuid: string,
@Param('category') category: string,
@Query() query: GetScheduleDeviceDto,
) {
try {
return await this.scheduleService.getDeviceScheduleByCategory(
deviceUuid,
category,
query.category,
);
} catch (error) {
throw new HttpException(

View File

@ -1 +1 @@
export * from './add.schedule.dto';
export * from './schedule.dto';

View File

@ -82,3 +82,12 @@ export class EnableScheduleDto {
@IsNotEmpty()
public enable: boolean;
}
export class GetScheduleDeviceDto {
@ApiProperty({
description: 'category',
required: true,
})
@IsString()
@IsNotEmpty()
public category: string;
}

View File

@ -1,7 +1,7 @@
import { Injectable, HttpException, HttpStatus } from '@nestjs/common';
import { TuyaContext } from '@tuya/tuya-connector-nodejs';
import { ConfigService } from '@nestjs/config';
import { AddScheduleDto, EnableScheduleDto } from '../dtos/add.schedule.dto';
import { AddScheduleDto, EnableScheduleDto } from '../dtos/schedule.dto';
import {
addScheduleDeviceInterface,
getDeviceScheduleInterface,