mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 22:57:55 +00:00
Merge branch 'dev' into SP-205-be-user-device-permission
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ProductRepository } from './../../../libs/common/src/modules/product/repositories/product.repository';
|
||||
import {
|
||||
Injectable,
|
||||
HttpException,
|
||||
@@ -33,6 +34,7 @@ export class DeviceService {
|
||||
private readonly configService: ConfigService,
|
||||
private readonly deviceRepository: DeviceRepository,
|
||||
private readonly groupDeviceRepository: GroupDeviceRepository,
|
||||
private readonly productRepository: ProductRepository,
|
||||
) {
|
||||
const accessKey = this.configService.get<string>('auth-config.ACCESS_KEY');
|
||||
const secretKey = this.configService.get<string>('auth-config.SECRET_KEY');
|
||||
@@ -249,18 +251,17 @@ export class DeviceService {
|
||||
|
||||
// Convert keys to camel case
|
||||
const camelCaseResponse = convertKeysToCamelCase(response);
|
||||
const deviceDetails = await this.deviceRepository.findOne({
|
||||
const product = await this.productRepository.findOne({
|
||||
where: {
|
||||
deviceTuyaUuid: deviceId,
|
||||
prodId: camelCaseResponse.result.productId,
|
||||
},
|
||||
relations: ['productDevice'],
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { productName, productId, ...rest } = camelCaseResponse.result;
|
||||
return {
|
||||
...rest,
|
||||
productUuid: deviceDetails.productDevice.uuid,
|
||||
productUuid: product.uuid,
|
||||
} as GetDeviceDetailsInterface;
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
|
||||
Reference in New Issue
Block a user