mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
Refactor device controller and service
This commit is contained in:
@ -200,10 +200,10 @@ export class DeviceController {
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('getaway/:gatewayUuid/devices')
|
||||
async getDevicesInGetaway(@Param('gatewayUuid') gatewayUuid: string) {
|
||||
@Get('gateway/:gatewayUuid/devices')
|
||||
async getDevicesInGateway(@Param('gatewayUuid') gatewayUuid: string) {
|
||||
try {
|
||||
return await this.deviceService.getDevicesInGetaway(gatewayUuid);
|
||||
return await this.deviceService.getDevicesInGateway(gatewayUuid);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
|
@ -428,7 +428,7 @@ export class DeviceService {
|
||||
});
|
||||
return device.permission[0].permissionType.type;
|
||||
}
|
||||
async getDevicesInGetaway(gatewayUuid: string) {
|
||||
async getDevicesInGateway(gatewayUuid: string) {
|
||||
try {
|
||||
const deviceDetails = await this.getDeviceByDeviceUuid(gatewayUuid);
|
||||
|
||||
@ -438,7 +438,7 @@ export class DeviceService {
|
||||
throw new BadRequestException('This is not a gateway device');
|
||||
}
|
||||
|
||||
const response = await this.getDevicesInGetawayTuya(
|
||||
const response = await this.getDevicesInGatewayTuya(
|
||||
deviceDetails.deviceTuyaUuid,
|
||||
);
|
||||
|
||||
@ -468,7 +468,7 @@ export class DeviceService {
|
||||
}
|
||||
}
|
||||
|
||||
async getDevicesInGetawayTuya(
|
||||
async getDevicesInGatewayTuya(
|
||||
deviceId: string,
|
||||
): Promise<GetDeviceDetailsInterface[]> {
|
||||
try {
|
||||
@ -479,7 +479,7 @@ export class DeviceService {
|
||||
});
|
||||
const camelCaseResponse = response.result.map((device: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { product_id, category, id, ...rest } = device;
|
||||
const { product_id, category, ...rest } = device;
|
||||
const camelCaseDevice = convertKeysToCamelCase({ ...rest });
|
||||
return camelCaseDevice as GetDeviceDetailsInterface[];
|
||||
});
|
||||
|
Reference in New Issue
Block a user