Merge branch 'dev' into delete-scene-device-endpoint

This commit is contained in:
faris Aljohari
2024-11-24 23:28:56 -06:00
22 changed files with 993 additions and 79 deletions

View File

@ -1,4 +1,3 @@
// automation.enum.ts
export enum ActionExecutorEnum { export enum ActionExecutorEnum {
DEVICE_ISSUE = 'device_issue', DEVICE_ISSUE = 'device_issue',
DELAY = 'delay', DELAY = 'delay',
@ -17,3 +16,5 @@ export const AUTOMATION_CONFIG = {
COMPARATOR: '==', COMPARATOR: '==',
SCENE_STATUS_VALUE: 'scene', SCENE_STATUS_VALUE: 'scene',
}; };
export const AUTOMATION_TYPE = 'automation';
export const AUTO_PREFIX = 'Auto_';

View File

@ -77,6 +77,10 @@ export class ControllerRoute {
'Retrieve list of spaces a user belongs to'; 'Retrieve list of spaces a user belongs to';
public static readonly GET_USER_SPACES_DESCRIPTION = public static readonly GET_USER_SPACES_DESCRIPTION =
'This endpoint retrieves all the spaces that a user is associated with, based on the user ID. It fetches the user spaces by querying the UserSpaceEntity to find the spaces where the user has an association.'; 'This endpoint retrieves all the spaces that a user is associated with, based on the user ID. It fetches the user spaces by querying the UserSpaceEntity to find the spaces where the user has an association.';
public static readonly VERIFY_CODE_AND_ADD_USER_SPACE_SUMMARY =
'Verify code and add user space';
public static readonly VERIFY_CODE_AND_ADD_USER_SPACE_DESCRIPTION =
'This endpoint verifies a provided code and associates the user with a space. It checks the validity of the code and, if valid, links the user to the corresponding space in the system.';
}; };
}; };
@ -244,4 +248,437 @@ export class ControllerRoute {
'Fetches a list of all products along with their associated device details'; 'Fetches a list of all products along with their associated device details';
}; };
}; };
static USER = class {
public static readonly ROUTE = '/user';
static ACTIONS = class {
public static readonly GET_USER_DETAILS_SUMMARY =
'Retrieve user details by user UUID';
public static readonly GET_USER_DETAILS_DESCRIPTION =
'This endpoint retrieves detailed information for a specific user based on their UUID.';
public static readonly UPDATE_PROFILE_PICTURE_SUMMARY =
'Update profile picture by user UUID';
public static readonly UPDATE_PROFILE_PICTURE_DESCRIPTION =
'This endpoint updates the profile picture for a user identified by their UUID.';
public static readonly UPDATE_REGION_SUMMARY =
'Update region by user UUID';
public static readonly UPDATE_REGION_DESCRIPTION =
'This endpoint updates the region information for a user identified by their UUID.';
public static readonly UPDATE_TIMEZONE_SUMMARY =
'Update timezone by user UUID';
public static readonly UPDATE_TIMEZONE_DESCRIPTION =
'This endpoint updates the timezone information for a user identified by their UUID.';
public static readonly UPDATE_NAME_SUMMARY = 'Update name by user UUID';
public static readonly UPDATE_NAME_DESCRIPTION =
'This endpoint updates the name for a user identified by their UUID.';
public static readonly DELETE_USER_SUMMARY = 'Delete user by UUID';
public static readonly DELETE_USER_DESCRIPTION =
'This endpoint deletes a user identified by their UUID. Accessible only by users with the Super Admin role.';
};
};
static AUTHENTICATION = class {
public static readonly ROUTE = 'authentication';
static ACTIONS = class {
public static readonly SIGN_UP_SUMMARY =
'Sign up a new user and return a JWT token';
public static readonly SIGN_UP_DESCRIPTION =
'This endpoint is used to register a new user by providing the user details. A JWT token will be generated and returned upon successful registration.';
public static readonly LOGIN_SUMMARY =
'Login a user and return an access token';
public static readonly LOGIN_DESCRIPTION =
'This endpoint allows an existing user to log in using their credentials. Upon successful login, an access token will be returned.';
public static readonly SEND_OTP_SUMMARY =
'Generate and send OTP to the user';
public static readonly SEND_OTP_DESCRIPTION =
'This endpoint generates and sends an OTP to the user for verification, such as for password reset or account verification.';
public static readonly VERIFY_OTP_SUMMARY =
'Verify the OTP entered by the user';
public static readonly VERIFY_OTP_DESCRIPTION =
'This endpoint verifies the OTP entered by the user. If the OTP is valid, the process continues (e.g., password reset).';
public static readonly FORGET_PASSWORD_SUMMARY =
'Reset the user password after OTP verification';
public static readonly FORGET_PASSWORD_DESCRIPTION =
'This endpoint allows users who have forgotten their password to reset it. After verifying the OTP, the user can set a new password.';
public static readonly USER_LIST_SUMMARY = 'Fetch the list of all users';
public static readonly USER_LIST_DESCRIPTION =
'This endpoint retrieves a list of all users in the system. Access is restricted to super admins only.';
public static readonly REFRESH_TOKEN_SUMMARY =
'Refresh the user session token';
public static readonly REFRESH_TOKEN_DESCRIPTION =
'This endpoint allows a user to refresh their session token. The user must provide a valid refresh token to get a new session token.';
};
};
static ROLE = class {
public static readonly ROUTE = 'role';
static ACTIONS = class {
public static readonly FETCH_ROLE_TYPES_SUMMARY =
'Fetch available role types';
public static readonly FETCH_ROLE_TYPES_DESCRIPTION =
'This endpoint retrieves all available role types in the system.';
public static readonly ADD_USER_ROLE_SUMMARY = 'Add a new user role';
public static readonly ADD_USER_ROLE_DESCRIPTION =
'This endpoint adds a new user role to the system based on the provided role data.';
};
};
static GROUP = class {
public static readonly ROUTE = 'group';
static ACTIONS = class {
public static readonly GET_GROUPS_BY_SPACE_UUID_SUMMARY =
'Get groups by space UUID';
public static readonly GET_GROUPS_BY_SPACE_UUID_DESCRIPTION =
'This endpoint retrieves all groups for a specific space, identified by the space UUID.';
public static readonly GET_UNIT_DEVICES_BY_GROUP_NAME_SUMMARY =
'Get devices by group name in a space';
public static readonly GET_UNIT_DEVICES_BY_GROUP_NAME_DESCRIPTION =
'This endpoint retrieves all devices in a specified group within a space, based on the group name and space UUID.';
};
};
static DEVICE = class {
public static readonly ROUTE = 'device';
static ACTIONS = class {
public static readonly ADD_DEVICE_TO_USER_SUMMARY = 'Add device to user';
public static readonly ADD_DEVICE_TO_USER_DESCRIPTION =
'This endpoint adds a device to a user in the system.';
public static readonly GET_DEVICES_BY_USER_SUMMARY =
'Get devices by user UUID';
public static readonly GET_DEVICES_BY_USER_DESCRIPTION =
'This endpoint retrieves all devices associated with a specific user.';
public static readonly GET_DEVICES_BY_SPACE_UUID_SUMMARY =
'Get devices by space UUID';
public static readonly GET_DEVICES_BY_SPACE_UUID_DESCRIPTION =
'This endpoint retrieves all devices associated with a specific space UUID.';
public static readonly UPDATE_DEVICE_IN_ROOM_SUMMARY =
'Update device in Space';
public static readonly UPDATE_DEVICE_IN_ROOM_DESCRIPTION =
'This endpoint updates the device in a specific space with new details.';
public static readonly GET_DEVICE_DETAILS_SUMMARY = 'Get device details';
public static readonly GET_DEVICE_DETAILS_DESCRIPTION =
'This endpoint retrieves details of a specific device by its UUID.';
public static readonly UPDATE_DEVICE_SUMMARY = 'Update device';
public static readonly UPDATE_DEVICE_DESCRIPTION =
'This endpoint updates the details of a device by its UUID.';
public static readonly GET_DEVICE_INSTRUCTION_SUMMARY =
'Get device instruction';
public static readonly GET_DEVICE_INSTRUCTION_DESCRIPTION =
'This endpoint retrieves the instruction details for a specific device.';
public static readonly GET_DEVICE_STATUS_SUMMARY = 'Get device status';
public static readonly GET_DEVICE_STATUS_DESCRIPTION =
'This endpoint retrieves the current status of a specific device.';
public static readonly CONTROL_DEVICE_SUMMARY = 'Control device';
public static readonly CONTROL_DEVICE_DESCRIPTION =
'This endpoint allows control operations (like power on/off) on a specific device.';
public static readonly UPDATE_DEVICE_FIRMWARE_SUMMARY =
'Update device firmware';
public static readonly UPDATE_DEVICE_FIRMWARE_DESCRIPTION =
'This endpoint updates the firmware of a specific device to the provided version.';
public static readonly GET_DEVICES_IN_GATEWAY_SUMMARY =
'Get devices in gateway';
public static readonly GET_DEVICES_IN_GATEWAY_DESCRIPTION =
'This endpoint retrieves all devices associated with a specific gateway.';
public static readonly GET_ALL_DEVICES_SUMMARY = 'Get all devices';
public static readonly GET_ALL_DEVICES_DESCRIPTION =
'This endpoint retrieves all devices in the system.';
public static readonly GET_DEVICE_LOGS_SUMMARY = 'Get device logs';
public static readonly GET_DEVICE_LOGS_DESCRIPTION =
'This endpoint retrieves the logs for a specific device based on device UUID.';
public static readonly BATCH_CONTROL_DEVICES_SUMMARY =
'Batch control devices';
public static readonly BATCH_CONTROL_DEVICES_DESCRIPTION =
'This endpoint controls a batch of devices with the specified actions.';
public static readonly BATCH_STATUS_DEVICES_SUMMARY =
'Batch status devices';
public static readonly BATCH_STATUS_DEVICES_DESCRIPTION =
'This endpoint retrieves the status of a batch of devices.';
public static readonly BATCH_FACTORY_RESET_DEVICES_SUMMARY =
'Batch factory reset devices';
public static readonly BATCH_FACTORY_RESET_DEVICES_DESCRIPTION =
'This endpoint performs a factory reset on a batch of devices.';
public static readonly GET_POWER_CLAMP_STATUS_SUMMARY =
'Get power clamp status';
public static readonly GET_POWER_CLAMP_STATUS_DESCRIPTION =
'This endpoint retrieves the status of a specific power clamp device.';
public static readonly ADD_SCENE_TO_DEVICE_SUMMARY =
'Add scene to device (4 Scene and 6 Scene devices only)';
public static readonly ADD_SCENE_TO_DEVICE_DESCRIPTION =
'This endpoint adds a scene to a specific switch device.';
public static readonly GET_SCENES_BY_DEVICE_SUMMARY =
'Get scenes by device (4 Scene and 6 Scene devices only)';
public static readonly GET_SCENES_BY_DEVICE_DESCRIPTION =
'This endpoint retrieves all scenes associated with a specific switch device.';
};
};
static DEVICE_PERMISSION = class {
public static readonly ROUTE = 'device-permission';
static ACTIONS = class {
public static readonly ADD_PERMISSION_SUMMARY =
'Add user permission for device';
public static readonly ADD_PERMISSION_DESCRIPTION =
'This endpoint adds a user permission for a specific device. Accessible only by users with the Super Admin role.';
public static readonly EDIT_PERMISSION_SUMMARY =
'Edit user permission for device';
public static readonly EDIT_PERMISSION_DESCRIPTION =
'This endpoint updates a user permission for a specific device. Accessible only by users with the Super Admin role.';
public static readonly FETCH_PERMISSION_SUMMARY =
'Fetch user permission for device';
public static readonly FETCH_PERMISSION_DESCRIPTION =
'This endpoint retrieves the user permission for a specific device. Accessible only by users with the Super Admin role.';
public static readonly DELETE_PERMISSION_SUMMARY =
'Delete user permission for device';
public static readonly DELETE_PERMISSION_DESCRIPTION =
'This endpoint deletes the user permission for a specific device. Accessible only by users with the Super Admin role.';
};
};
static USER_NOTIFICATION = class {
public static readonly ROUTE = 'user-notification/subscription';
static ACTIONS = class {
public static readonly ADD_SUBSCRIPTION_SUMMARY =
'Add user notification subscription';
public static readonly ADD_SUBSCRIPTION_DESCRIPTION =
'This endpoint adds a subscription for user notifications.';
public static readonly FETCH_SUBSCRIPTIONS_SUMMARY =
'Fetch user notification subscriptions';
public static readonly FETCH_SUBSCRIPTIONS_DESCRIPTION =
'This endpoint retrieves the subscriptions of a specific user based on their UUID.';
public static readonly UPDATE_SUBSCRIPTION_SUMMARY =
'Update user notification subscription';
public static readonly UPDATE_SUBSCRIPTION_DESCRIPTION =
'This endpoint updates the notification subscription details for a user.';
};
};
static AUTOMATION = class {
public static readonly ROUTE = 'automation';
static ACTIONS = class {
public static readonly ADD_AUTOMATION_SUMMARY = 'Add automation';
public static readonly ADD_AUTOMATION_DESCRIPTION =
'This endpoint creates a new automation based on the provided details.';
public static readonly GET_AUTOMATION_BY_SPACE_SUMMARY =
'Get automation by space';
public static readonly GET_AUTOMATION_BY_SPACE_DESCRIPTION =
'This endpoint retrieves the automations associated with a particular space.';
public static readonly GET_AUTOMATION_DETAILS_SUMMARY =
'Get automation details';
public static readonly GET_AUTOMATION_DETAILS_DESCRIPTION =
'This endpoint retrieves detailed information about a specific automation.';
public static readonly DELETE_AUTOMATION_SUMMARY = 'Delete automation';
public static readonly DELETE_AUTOMATION_DESCRIPTION =
'This endpoint deletes an automation identified by its UUID.';
public static readonly UPDATE_AUTOMATION_SUMMARY = 'Update automation';
public static readonly UPDATE_AUTOMATION_DESCRIPTION =
'This endpoint updates the details of an existing automation.';
public static readonly UPDATE_AUTOMATION_STATUS_SUMMARY =
'Update automation status';
public static readonly UPDATE_AUTOMATION_STATUS_DESCRIPTION =
'This endpoint updates the status of an automation identified by its UUID (enabled/disabled).';
};
};
static DOOR_LOCK = class {
public static readonly ROUTE = 'door-lock';
static ACTIONS = class {
public static readonly ADD_ONLINE_TEMPORARY_PASSWORD_SUMMARY =
'Add online temporary password';
public static readonly ADD_ONLINE_TEMPORARY_PASSWORD_DESCRIPTION =
'This endpoint allows you to add an online temporary password to a door lock.';
public static readonly ADD_OFFLINE_ONE_TIME_TEMPORARY_PASSWORD_SUMMARY =
'Add offline one-time temporary password';
public static readonly ADD_OFFLINE_ONE_TIME_TEMPORARY_PASSWORD_DESCRIPTION =
'This endpoint allows you to add an offline one-time temporary password to a door lock.';
public static readonly ADD_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORD_SUMMARY =
'Add offline multiple-time temporary password';
public static readonly ADD_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORD_DESCRIPTION =
'This endpoint allows you to add an offline multiple-time temporary password to a door lock.';
public static readonly GET_ONLINE_TEMPORARY_PASSWORDS_SUMMARY =
'Get online temporary passwords';
public static readonly GET_ONLINE_TEMPORARY_PASSWORDS_DESCRIPTION =
'This endpoint retrieves the list of online temporary passwords for a door lock.';
public static readonly DELETE_ONLINE_TEMPORARY_PASSWORD_SUMMARY =
'Delete online temporary password';
public static readonly DELETE_ONLINE_TEMPORARY_PASSWORD_DESCRIPTION =
'This endpoint deletes an online temporary password for a door lock.';
public static readonly GET_OFFLINE_ONE_TIME_TEMPORARY_PASSWORDS_SUMMARY =
'Get offline one-time temporary passwords';
public static readonly GET_OFFLINE_ONE_TIME_TEMPORARY_PASSWORDS_DESCRIPTION =
'This endpoint retrieves the list of offline one-time temporary passwords for a door lock.';
public static readonly GET_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORDS_SUMMARY =
'Get offline multiple-time temporary passwords';
public static readonly GET_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORDS_DESCRIPTION =
'This endpoint retrieves the list of offline multiple-time temporary passwords for a door lock.';
public static readonly UPDATE_OFFLINE_TEMPORARY_PASSWORD_SUMMARY =
'Update offline temporary password';
public static readonly UPDATE_OFFLINE_TEMPORARY_PASSWORD_DESCRIPTION =
'This endpoint updates an offline temporary password for a door lock.';
public static readonly OPEN_DOOR_LOCK_SUMMARY = 'Open door lock';
public static readonly OPEN_DOOR_LOCK_DESCRIPTION =
'This endpoint allows you to open a door lock.';
};
};
static TIMEZONE = class {
public static readonly ROUTE = 'timezone';
static ACTIONS = class {
public static readonly GET_ALL_TIME_ZONES_SUMMARY = 'Get all time zones';
public static readonly GET_ALL_TIME_ZONES_DESCRIPTION =
'This endpoint retrieves all available time zones.';
};
};
static VISITOR_PASSWORD = class {
public static readonly ROUTE = 'visitor-password';
static ACTIONS = class {
public static readonly ADD_ONLINE_TEMP_PASSWORD_MULTIPLE_TIME_SUMMARY =
'Add online temporary passwords (multiple-time)';
public static readonly ADD_ONLINE_TEMP_PASSWORD_MULTIPLE_TIME_DESCRIPTION =
'This endpoint adds multiple online temporary passwords for door locks.';
public static readonly ADD_ONLINE_TEMP_PASSWORD_ONE_TIME_SUMMARY =
'Add online temporary password (one-time)';
public static readonly ADD_ONLINE_TEMP_PASSWORD_ONE_TIME_DESCRIPTION =
'This endpoint adds a one-time online temporary password for a door lock.';
public static readonly ADD_OFFLINE_TEMP_PASSWORD_ONE_TIME_SUMMARY =
'Add offline temporary password (one-time)';
public static readonly ADD_OFFLINE_TEMP_PASSWORD_ONE_TIME_DESCRIPTION =
'This endpoint adds a one-time offline temporary password for a door lock.';
public static readonly ADD_OFFLINE_TEMP_PASSWORD_MULTIPLE_TIME_SUMMARY =
'Add offline temporary passwords (multiple-time)';
public static readonly ADD_OFFLINE_TEMP_PASSWORD_MULTIPLE_TIME_DESCRIPTION =
'This endpoint adds multiple offline temporary passwords for door locks.';
public static readonly GET_VISITOR_PASSWORD_SUMMARY =
'Get visitor passwords';
public static readonly GET_VISITOR_PASSWORD_DESCRIPTION =
'This endpoint retrieves all visitor passwords.';
public static readonly GET_VISITOR_DEVICES_SUMMARY =
'Get visitor devices';
public static readonly GET_VISITOR_DEVICES_DESCRIPTION =
'This endpoint retrieves all devices associated with visitor passwords.';
};
};
static SCHEDULE = class {
public static readonly ROUTE = 'schedule';
static ACTIONS = class {
public static readonly ADD_DEVICE_SCHEDULE_SUMMARY =
'Add device schedule';
public static readonly ADD_DEVICE_SCHEDULE_DESCRIPTION =
'This endpoint allows you to add a schedule for a specific device.';
public static readonly GET_DEVICE_SCHEDULE_BY_CATEGORY_SUMMARY =
'Get device schedule by category';
public static readonly GET_DEVICE_SCHEDULE_BY_CATEGORY_DESCRIPTION =
'This endpoint retrieves the schedule for a specific device based on the given category.';
public static readonly DELETE_DEVICE_SCHEDULE_SUMMARY =
'Delete device schedule';
public static readonly DELETE_DEVICE_SCHEDULE_DESCRIPTION =
'This endpoint deletes a specific schedule for a device.';
public static readonly ENABLE_DEVICE_SCHEDULE_SUMMARY =
'Enable device schedule';
public static readonly ENABLE_DEVICE_SCHEDULE_DESCRIPTION =
'This endpoint enables a device schedule for a specific device.';
public static readonly UPDATE_DEVICE_SCHEDULE_SUMMARY =
'Update device schedule';
public static readonly UPDATE_DEVICE_SCHEDULE_DESCRIPTION =
'This endpoint updates the schedule for a specific device.';
};
};
static DEVICE_STATUS_FIREBASE = class {
public static readonly ROUTE = 'device-status-firebase';
static ACTIONS = class {
public static readonly ADD_DEVICE_STATUS_SUMMARY =
'Add device status to Firebase';
public static readonly ADD_DEVICE_STATUS_DESCRIPTION =
'This endpoint adds a device status in Firebase based on the provided device UUID.';
public static readonly GET_DEVICE_STATUS_SUMMARY =
'Get device status from Firebase';
public static readonly GET_DEVICE_STATUS_DESCRIPTION =
'This endpoint retrieves a device status from Firebase using the device UUID.';
};
};
static DEVICE_MESSAGES_SUBSCRIPTION = class {
public static readonly ROUTE = 'device-messages/subscription';
static ACTIONS = class {
public static readonly ADD_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY =
'Add device messages subscription';
public static readonly ADD_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION =
'This endpoint adds a subscription for device messages.';
public static readonly GET_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY =
'Get device messages subscription';
public static readonly GET_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION =
'This endpoint fetches a users subscription for a specific device.';
public static readonly DELETE_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY =
'Delete device messages subscription';
public static readonly DELETE_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION =
'This endpoint deletes a users subscription for device messages.';
};
};
} }

View File

@ -1,13 +1,14 @@
import { Controller, Post, Param } from '@nestjs/common'; import { Controller, Post, Param } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { AddDeviceStatusDto } from '../dtos/add.devices-status.dto'; import { AddDeviceStatusDto } from '../dtos/add.devices-status.dto';
import { DeviceStatusFirebaseService } from '../services/devices-status.service'; import { DeviceStatusFirebaseService } from '../services/devices-status.service';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Device Status Firebase Module') @ApiTags('Device Status Firebase Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'device-status-firebase', path: ControllerRoute.DEVICE_STATUS_FIREBASE.ROUTE,
}) })
export class DeviceStatusFirebaseController { export class DeviceStatusFirebaseController {
constructor( constructor(
@ -16,6 +17,13 @@ export class DeviceStatusFirebaseController {
@ApiBearerAuth() @ApiBearerAuth()
@Post(':deviceTuyaUuid') @Post(':deviceTuyaUuid')
@ApiOperation({
summary:
ControllerRoute.DEVICE_STATUS_FIREBASE.ACTIONS.ADD_DEVICE_STATUS_SUMMARY,
description:
ControllerRoute.DEVICE_STATUS_FIREBASE.ACTIONS
.ADD_DEVICE_STATUS_DESCRIPTION,
})
async addDeviceStatus( async addDeviceStatus(
@Param('deviceTuyaUuid') deviceTuyaUuid: string, @Param('deviceTuyaUuid') deviceTuyaUuid: string,
): Promise<AddDeviceStatusDto> { ): Promise<AddDeviceStatusDto> {

View File

@ -10,7 +10,7 @@ import {
} from '@nestjs/common'; } from '@nestjs/common';
import { UserAuthService } from '../services/user-auth.service'; import { UserAuthService } from '../services/user-auth.service';
import { UserSignUpDto } from '../dtos/user-auth.dto'; import { UserSignUpDto } from '../dtos/user-auth.dto';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ResponseMessage } from '../../../libs/common/src/response/response.decorator'; import { ResponseMessage } from '../../../libs/common/src/response/response.decorator';
import { UserLoginDto } from '../dtos/user-login.dto'; import { UserLoginDto } from '../dtos/user-login.dto';
import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos'; import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos';
@ -18,17 +18,22 @@ import { RefreshTokenGuard } from '@app/common/guards/jwt-refresh.auth.guard';
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard'; import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { OtpType } from '@app/common/constants/otp-type.enum'; import { OtpType } from '@app/common/constants/otp-type.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'authentication', path: ControllerRoute.AUTHENTICATION.ROUTE,
}) })
@ApiTags('Auth') @ApiTags('Authentication Module')
export class UserAuthController { export class UserAuthController {
constructor(private readonly userAuthService: UserAuthService) {} constructor(private readonly userAuthService: UserAuthService) {}
@ResponseMessage('User Registered Successfully') @ResponseMessage('User Registered Successfully')
@Post('user/signup') @Post('user/signup')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.SIGN_UP_SUMMARY,
description: ControllerRoute.AUTHENTICATION.ACTIONS.SIGN_UP_DESCRIPTION,
})
async signUp(@Body() userSignUpDto: UserSignUpDto) { async signUp(@Body() userSignUpDto: UserSignUpDto) {
const signupUser = await this.userAuthService.signUp(userSignUpDto); const signupUser = await this.userAuthService.signUp(userSignUpDto);
return { return {
@ -41,8 +46,12 @@ export class UserAuthController {
}; };
} }
@ResponseMessage('user logged in successfully') @ResponseMessage('User Logged in Successfully')
@Post('user/login') @Post('user/login')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.LOGIN_SUMMARY,
description: ControllerRoute.AUTHENTICATION.ACTIONS.LOGIN_DESCRIPTION,
})
async userLogin(@Body() data: UserLoginDto) { async userLogin(@Body() data: UserLoginDto) {
const accessToken = await this.userAuthService.userLogin(data); const accessToken = await this.userAuthService.userLogin(data);
return { return {
@ -53,6 +62,10 @@ export class UserAuthController {
} }
@Post('user/send-otp') @Post('user/send-otp')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.SEND_OTP_SUMMARY,
description: ControllerRoute.AUTHENTICATION.ACTIONS.SEND_OTP_DESCRIPTION,
})
async sendOtp(@Body() otpDto: UserOtpDto) { async sendOtp(@Body() otpDto: UserOtpDto) {
const otpCode = await this.userAuthService.generateOTP(otpDto); const otpCode = await this.userAuthService.generateOTP(otpDto);
return { return {
@ -60,11 +73,15 @@ export class UserAuthController {
data: { data: {
...otpCode, ...otpCode,
}, },
message: 'Otp Send Successfully', message: 'Otp Sent Successfully',
}; };
} }
@Post('user/verify-otp') @Post('user/verify-otp')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.VERIFY_OTP_SUMMARY,
description: ControllerRoute.AUTHENTICATION.ACTIONS.VERIFY_OTP_DESCRIPTION,
})
async verifyOtp(@Body() verifyOtpDto: VerifyOtpDto) { async verifyOtp(@Body() verifyOtpDto: VerifyOtpDto) {
await this.userAuthService.verifyOTP(verifyOtpDto); await this.userAuthService.verifyOTP(verifyOtpDto);
return { return {
@ -75,6 +92,11 @@ export class UserAuthController {
} }
@Post('user/forget-password') @Post('user/forget-password')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.FORGET_PASSWORD_SUMMARY,
description:
ControllerRoute.AUTHENTICATION.ACTIONS.FORGET_PASSWORD_DESCRIPTION,
})
async forgetPassword(@Body() forgetPasswordDto: ForgetPasswordDto) { async forgetPassword(@Body() forgetPasswordDto: ForgetPasswordDto) {
const otpResult = await this.userAuthService.verifyOTP( const otpResult = await this.userAuthService.verifyOTP(
{ {
@ -102,6 +124,10 @@ export class UserAuthController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard) @UseGuards(SuperAdminRoleGuard)
@Get('user') @Get('user')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.USER_LIST_SUMMARY,
description: ControllerRoute.AUTHENTICATION.ACTIONS.USER_LIST_DESCRIPTION,
})
async userList() { async userList() {
const userList = await this.userAuthService.userList(); const userList = await this.userAuthService.userList();
return { return {
@ -114,6 +140,11 @@ export class UserAuthController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(RefreshTokenGuard) @UseGuards(RefreshTokenGuard)
@Get('refresh-token') @Get('refresh-token')
@ApiOperation({
summary: ControllerRoute.AUTHENTICATION.ACTIONS.REFRESH_TOKEN_SUMMARY,
description:
ControllerRoute.AUTHENTICATION.ACTIONS.REFRESH_TOKEN_DESCRIPTION,
})
async refreshToken(@Req() req) { async refreshToken(@Req() req) {
const refreshToken = await this.userAuthService.refreshToken( const refreshToken = await this.userAuthService.refreshToken(
req.user.uuid, req.user.uuid,

View File

@ -10,7 +10,7 @@ import {
Put, Put,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { import {
AddAutomationDto, AddAutomationDto,
UpdateAutomationDto, UpdateAutomationDto,
@ -19,11 +19,12 @@ import {
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { AutomationParamDto, SpaceParamDto } from '../dtos'; import { AutomationParamDto, SpaceParamDto } from '../dtos';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Automation Module') @ApiTags('Automation Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'automation', path: ControllerRoute.AUTOMATION.ROUTE,
}) })
export class AutomationController { export class AutomationController {
constructor(private readonly automationService: AutomationService) {} constructor(private readonly automationService: AutomationService) {}
@ -31,6 +32,10 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post() @Post()
@ApiOperation({
summary: ControllerRoute.AUTOMATION.ACTIONS.ADD_AUTOMATION_SUMMARY,
description: ControllerRoute.AUTOMATION.ACTIONS.ADD_AUTOMATION_DESCRIPTION,
})
async addAutomation(@Body() addAutomationDto: AddAutomationDto) { async addAutomation(@Body() addAutomationDto: AddAutomationDto) {
const automation = const automation =
await this.automationService.addAutomation(addAutomationDto); await this.automationService.addAutomation(addAutomationDto);
@ -45,6 +50,11 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':spaceUuid') @Get(':spaceUuid')
@ApiOperation({
summary: ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_BY_SPACE_SUMMARY,
description:
ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_BY_SPACE_DESCRIPTION,
})
async getAutomationBySpace(@Param() param: SpaceParamDto) { async getAutomationBySpace(@Param() param: SpaceParamDto) {
const automation = await this.automationService.getAutomationBySpace( const automation = await this.automationService.getAutomationBySpace(
param.spaceUuid, param.spaceUuid,
@ -55,6 +65,11 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('details/:automationUuid') @Get('details/:automationUuid')
@ApiOperation({
summary: ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_DETAILS_SUMMARY,
description:
ControllerRoute.AUTOMATION.ACTIONS.GET_AUTOMATION_DETAILS_DESCRIPTION,
})
async getAutomationDetails(@Param() param: AutomationParamDto) { async getAutomationDetails(@Param() param: AutomationParamDto) {
const automation = await this.automationService.getAutomationDetails( const automation = await this.automationService.getAutomationDetails(
param.automationUuid, param.automationUuid,
@ -65,6 +80,11 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Delete(':automationUuid') @Delete(':automationUuid')
@ApiOperation({
summary: ControllerRoute.AUTOMATION.ACTIONS.DELETE_AUTOMATION_SUMMARY,
description:
ControllerRoute.AUTOMATION.ACTIONS.DELETE_AUTOMATION_DESCRIPTION,
})
async deleteAutomation(@Param() param: AutomationParamDto) { async deleteAutomation(@Param() param: AutomationParamDto) {
await this.automationService.deleteAutomation(param); await this.automationService.deleteAutomation(param);
return { return {
@ -76,6 +96,11 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put(':automationUuid') @Put(':automationUuid')
@ApiOperation({
summary: ControllerRoute.AUTOMATION.ACTIONS.UPDATE_AUTOMATION_SUMMARY,
description:
ControllerRoute.AUTOMATION.ACTIONS.UPDATE_AUTOMATION_DESCRIPTION,
})
async updateAutomation( async updateAutomation(
@Body() updateAutomationDto: UpdateAutomationDto, @Body() updateAutomationDto: UpdateAutomationDto,
@Param() param: AutomationParamDto, @Param() param: AutomationParamDto,
@ -95,6 +120,12 @@ export class AutomationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('status/:automationUuid') @Put('status/:automationUuid')
@ApiOperation({
summary:
ControllerRoute.AUTOMATION.ACTIONS.UPDATE_AUTOMATION_STATUS_SUMMARY,
description:
ControllerRoute.AUTOMATION.ACTIONS.UPDATE_AUTOMATION_STATUS_DESCRIPTION,
})
async updateAutomationStatus( async updateAutomationStatus(
@Body() updateAutomationStatusDto: UpdateAutomationStatusDto, @Body() updateAutomationStatusDto: UpdateAutomationStatusDto,
@Param() param: AutomationParamDto, @Param() param: AutomationParamDto,

View File

@ -26,6 +26,8 @@ import {
import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter'; import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter';
import { import {
ActionExecutorEnum, ActionExecutorEnum,
AUTO_PREFIX,
AUTOMATION_TYPE,
EntityTypeEnum, EntityTypeEnum,
} from '@app/common/constants/automation.enum'; } from '@app/common/constants/automation.enum';
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service'; import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
@ -154,14 +156,16 @@ export class AutomationService {
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST); throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
} }
return response.result.list.map((item) => { return response.result.list
return { .filter((item) => item.name && !item.name.startsWith(AUTO_PREFIX))
id: item.id, .map((item) => {
name: item.name, return {
status: item.status, id: item.id,
type: 'automation', name: item.name,
}; status: item.status,
}); type: AUTOMATION_TYPE,
};
});
} catch (err) { } catch (err) {
if (err instanceof BadRequestException) { if (err instanceof BadRequestException) {
throw err; // Re-throw BadRequestException throw err; // Re-throw BadRequestException

View File

@ -8,17 +8,18 @@ import {
Post, Post,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { DeviceMessagesSubscriptionService } from '../services/device-messages.service'; import { DeviceMessagesSubscriptionService } from '../services/device-messages.service';
import { DeviceMessagesAddDto } from '../dtos/device-messages.dto'; import { DeviceMessagesAddDto } from '../dtos/device-messages.dto';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Device Messages Status Module') @ApiTags('Device Messages Status Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'device-messages/subscription', path: ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ROUTE,
}) })
export class DeviceMessagesSubscriptionController { export class DeviceMessagesSubscriptionController {
constructor( constructor(
@ -28,6 +29,14 @@ export class DeviceMessagesSubscriptionController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post() @Post()
@ApiOperation({
summary:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.ADD_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY,
description:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.ADD_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION,
})
async addDeviceMessagesSubscription( async addDeviceMessagesSubscription(
@Body() deviceMessagesAddDto: DeviceMessagesAddDto, @Body() deviceMessagesAddDto: DeviceMessagesAddDto,
) { ) {
@ -45,6 +54,14 @@ export class DeviceMessagesSubscriptionController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':deviceUuid/user/:userUuid') @Get(':deviceUuid/user/:userUuid')
@ApiOperation({
summary:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.GET_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY,
description:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.GET_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION,
})
async getDeviceMessagesSubscription( async getDeviceMessagesSubscription(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Param('userUuid') userUuid: string, @Param('userUuid') userUuid: string,
@ -60,9 +77,18 @@ export class DeviceMessagesSubscriptionController {
data: deviceDetails, data: deviceDetails,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Delete() @Delete()
@ApiOperation({
summary:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.DELETE_DEVICE_MESSAGES_SUBSCRIPTION_SUMMARY,
description:
ControllerRoute.DEVICE_MESSAGES_SUBSCRIPTION.ACTIONS
.DELETE_DEVICE_MESSAGES_SUBSCRIPTION_DESCRIPTION,
})
async deleteDeviceMessagesSubscription( async deleteDeviceMessagesSubscription(
@Body() deviceMessagesAddDto: DeviceMessagesAddDto, @Body() deviceMessagesAddDto: DeviceMessagesAddDto,
) { ) {

View File

@ -12,7 +12,7 @@ import {
Put, Put,
Delete, Delete,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { import {
AddDeviceDto, AddDeviceDto,
AddSceneToFourSceneDeviceDto, AddSceneToFourSceneDeviceDto,
@ -33,19 +33,24 @@ import { CheckDeviceGuard } from 'src/guards/device.guard';
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard'; import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { CheckFourAndSixSceneDeviceTypeGuard } from 'src/guards/scene.device.type.guard'; import { CheckFourAndSixSceneDeviceTypeGuard } from 'src/guards/scene.device.type.guard';
import { ControllerRoute } from '@app/common/constants/controller-route';
import { BaseResponseDto } from '@app/common/dto/base.response.dto'; import { BaseResponseDto } from '@app/common/dto/base.response.dto';
import { DeviceSceneParamDto } from '../dtos/device.param.dto'; import { DeviceSceneParamDto } from '../dtos/device.param.dto';
@ApiTags('Device Module') @ApiTags('Device Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'device', path: ControllerRoute.DEVICE.ROUTE,
}) })
export class DeviceController { export class DeviceController {
constructor(private readonly deviceService: DeviceService) {} constructor(private readonly deviceService: DeviceService) {}
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard, CheckDeviceGuard) @UseGuards(SuperAdminRoleGuard, CheckDeviceGuard)
@Post() @Post()
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.ADD_DEVICE_TO_USER_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.ADD_DEVICE_TO_USER_DESCRIPTION,
})
async addDeviceUser(@Body() addDeviceDto: AddDeviceDto) { async addDeviceUser(@Body() addDeviceDto: AddDeviceDto) {
const device = await this.deviceService.addDeviceUser(addDeviceDto); const device = await this.deviceService.addDeviceUser(addDeviceDto);
@ -59,6 +64,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('user/:userUuid') @Get('user/:userUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_BY_USER_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_BY_USER_DESCRIPTION,
})
async getDevicesByUser(@Param('userUuid') userUuid: string) { async getDevicesByUser(@Param('userUuid') userUuid: string) {
return await this.deviceService.getDevicesByUser(userUuid); return await this.deviceService.getDevicesByUser(userUuid);
} }
@ -66,12 +75,22 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('space/:spaceUuid') @Get('space/:spaceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_BY_SPACE_UUID_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_BY_SPACE_UUID_DESCRIPTION,
})
async getDevicesByUnitId(@Param('spaceUuid') spaceUuid: string) { async getDevicesByUnitId(@Param('spaceUuid') spaceUuid: string) {
return await this.deviceService.getDevicesBySpaceUuid(spaceUuid); return await this.deviceService.getDevicesBySpaceUuid(spaceUuid);
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard, CheckRoomGuard) @UseGuards(JwtAuthGuard, CheckRoomGuard)
@Put('space') @Put('space')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_IN_ROOM_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_IN_ROOM_DESCRIPTION,
})
async updateDeviceInRoom( async updateDeviceInRoom(
@Body() updateDeviceInSpaceDto: UpdateDeviceInSpaceDto, @Body() updateDeviceInSpaceDto: UpdateDeviceInSpaceDto,
) { ) {
@ -90,6 +109,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':deviceUuid') @Get(':deviceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_DETAILS_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_DETAILS_DESCRIPTION,
})
async getDeviceDetailsByDeviceId( async getDeviceDetailsByDeviceId(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Req() req: any, @Req() req: any,
@ -103,6 +126,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put(':deviceUuid') @Put(':deviceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_DESCRIPTION,
})
async updateDevice( async updateDevice(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Body() updateDeviceDto: UpdateDeviceDto, @Body() updateDeviceDto: UpdateDeviceDto,
@ -123,6 +150,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':deviceUuid/functions') @Get(':deviceUuid/functions')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_INSTRUCTION_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_INSTRUCTION_DESCRIPTION,
})
async getDeviceInstructionByDeviceId( async getDeviceInstructionByDeviceId(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
) { ) {
@ -131,6 +163,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':deviceUuid/functions/status') @Get(':deviceUuid/functions/status')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_STATUS_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_STATUS_DESCRIPTION,
})
async getDevicesInstructionStatus(@Param('deviceUuid') deviceUuid: string) { async getDevicesInstructionStatus(@Param('deviceUuid') deviceUuid: string) {
return await this.deviceService.getDevicesInstructionStatus(deviceUuid); return await this.deviceService.getDevicesInstructionStatus(deviceUuid);
} }
@ -138,6 +174,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post(':deviceUuid/control') @Post(':deviceUuid/control')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.CONTROL_DEVICE_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.CONTROL_DEVICE_DESCRIPTION,
})
async controlDevice( async controlDevice(
@Body() controlDeviceDto: ControlDeviceDto, @Body() controlDeviceDto: ControlDeviceDto,
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@ -147,6 +187,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post(':deviceUuid/firmware/:firmwareVersion') @Post(':deviceUuid/firmware/:firmwareVersion')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_FIRMWARE_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.UPDATE_DEVICE_FIRMWARE_DESCRIPTION,
})
async updateDeviceFirmware( async updateDeviceFirmware(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Param('firmwareVersion') firmwareVersion: number, @Param('firmwareVersion') firmwareVersion: number,
@ -159,12 +204,21 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('gateway/:gatewayUuid/devices') @Get('gateway/:gatewayUuid/devices')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_IN_GATEWAY_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.GET_DEVICES_IN_GATEWAY_DESCRIPTION,
})
async getDevicesInGateway(@Param('gatewayUuid') gatewayUuid: string) { async getDevicesInGateway(@Param('gatewayUuid') gatewayUuid: string) {
return await this.deviceService.getDevicesInGateway(gatewayUuid); return await this.deviceService.getDevicesInGateway(gatewayUuid);
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get() @Get()
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_ALL_DEVICES_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.GET_ALL_DEVICES_DESCRIPTION,
})
async getAllDevices() { async getAllDevices() {
return await this.deviceService.getAllDevices(); return await this.deviceService.getAllDevices();
} }
@ -172,6 +226,10 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('report-logs/:deviceUuid') @Get('report-logs/:deviceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_LOGS_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.GET_DEVICE_LOGS_DESCRIPTION,
})
async getBuildingChildByUuid( async getBuildingChildByUuid(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Query() query: GetDeviceLogsDto, @Query() query: GetDeviceLogsDto,
@ -181,6 +239,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('control/batch') @Post('control/batch')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.BATCH_CONTROL_DEVICES_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.BATCH_CONTROL_DEVICES_DESCRIPTION,
})
async batchControlDevices( async batchControlDevices(
@Body() batchControlDevicesDto: BatchControlDevicesDto, @Body() batchControlDevicesDto: BatchControlDevicesDto,
) { ) {
@ -189,6 +252,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('status/batch') @Get('status/batch')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.BATCH_STATUS_DEVICES_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.BATCH_STATUS_DEVICES_DESCRIPTION,
})
async batchStatusDevices( async batchStatusDevices(
@Query() batchStatusDevicesDto: BatchStatusDevicesDto, @Query() batchStatusDevicesDto: BatchStatusDevicesDto,
) { ) {
@ -197,6 +265,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('factory/reset/:deviceUuid') @Post('factory/reset/:deviceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.BATCH_FACTORY_RESET_DEVICES_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.BATCH_FACTORY_RESET_DEVICES_DESCRIPTION,
})
async batchFactoryResetDevices( async batchFactoryResetDevices(
@Body() batchFactoryResetDevicesDto: BatchFactoryResetDevicesDto, @Body() batchFactoryResetDevicesDto: BatchFactoryResetDevicesDto,
) { ) {
@ -207,6 +280,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':powerClampUuid/power-clamp/status') @Get(':powerClampUuid/power-clamp/status')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_POWER_CLAMP_STATUS_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.GET_POWER_CLAMP_STATUS_DESCRIPTION,
})
async getPowerClampInstructionStatus( async getPowerClampInstructionStatus(
@Param('powerClampUuid') powerClampUuid: string, @Param('powerClampUuid') powerClampUuid: string,
) { ) {
@ -216,6 +294,10 @@ export class DeviceController {
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard, CheckFourAndSixSceneDeviceTypeGuard) @UseGuards(JwtAuthGuard, CheckFourAndSixSceneDeviceTypeGuard)
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.ADD_SCENE_TO_DEVICE_SUMMARY,
description: ControllerRoute.DEVICE.ACTIONS.ADD_SCENE_TO_DEVICE_DESCRIPTION,
})
@Post(':deviceUuid/scenes') @Post(':deviceUuid/scenes')
async addSceneToSceneDevice( async addSceneToSceneDevice(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@ -236,6 +318,11 @@ export class DeviceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard, CheckFourAndSixSceneDeviceTypeGuard) @UseGuards(JwtAuthGuard, CheckFourAndSixSceneDeviceTypeGuard)
@Get(':deviceUuid/scenes') @Get(':deviceUuid/scenes')
@ApiOperation({
summary: ControllerRoute.DEVICE.ACTIONS.GET_SCENES_BY_DEVICE_SUMMARY,
description:
ControllerRoute.DEVICE.ACTIONS.GET_SCENES_BY_DEVICE_DESCRIPTION,
})
async getScenesBySceneDevice( async getScenesBySceneDevice(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Query() getSceneFourSceneDeviceDto: GetSceneFourSceneDeviceDto, @Query() getSceneFourSceneDeviceDto: GetSceneFourSceneDeviceDto,

View File

@ -175,31 +175,40 @@ export class DeviceService {
'permission.permissionType', 'permission.permissionType',
], ],
}); });
const devicesData = await Promise.all( const safeFetchDeviceDetails = async (device: any) => {
devices.map(async (device) => { try {
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
device.deviceTuyaUuid,
);
return { return {
haveRoom: device.spaceDevice ? true : false, haveRoom: !!device.spaceDevice,
productUuid: device.productDevice.uuid, productUuid: device.productDevice.uuid,
productType: device.productDevice.prodType, productType: device.productDevice.prodType,
permissionType: device.permission[0].permissionType.type, permissionType: device.permission[0].permissionType.type,
...(await this.getDeviceDetailsByDeviceIdTuya( ...tuyaDetails,
device.deviceTuyaUuid,
)),
uuid: device.uuid, uuid: device.uuid,
} as GetDeviceDetailsInterface; } as GetDeviceDetailsInterface;
}), } catch (error) {
console.warn(
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
);
return null;
}
};
const devicesData = await Promise.all(
devices.map(safeFetchDeviceDetails),
); );
return devicesData; return devicesData.filter(Boolean); // Remove null or undefined entries
} catch (error) { } catch (error) {
// Handle the error here console.error('Error fetching devices by user:', error);
throw new HttpException( throw new HttpException(
'User does not have any devices', 'User does not have any devices',
HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND,
); );
} }
} }
async getDevicesBySpaceId( async getDevicesBySpaceId(
getDeviceBySpaceUuidDto: GetDeviceBySpaceUuidDto, getDeviceBySpaceUuidDto: GetDeviceBySpaceUuidDto,
userUuid: string, userUuid: string,

View File

@ -10,23 +10,31 @@ import {
UseGuards, UseGuards,
Put, Put,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { AddDoorLockOnlineDto } from '../dtos/add.online-temp.dto'; import { AddDoorLockOnlineDto } from '../dtos/add.online-temp.dto';
import { AddDoorLockOfflineTempMultipleTimeDto } from '../dtos/add.offline-temp.dto'; import { AddDoorLockOfflineTempMultipleTimeDto } from '../dtos/add.offline-temp.dto';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { UpdateDoorLockOfflineTempDto } from '../dtos/update.offline-temp.dto'; import { UpdateDoorLockOfflineTempDto } from '../dtos/update.offline-temp.dto';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Door Lock Module') @ApiTags('Door Lock Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'door-lock', path: ControllerRoute.DOOR_LOCK.ROUTE,
}) })
export class DoorLockController { export class DoorLockController {
constructor(private readonly doorLockService: DoorLockService) {} constructor(private readonly doorLockService: DoorLockService) {}
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/online/:doorLockUuid') @Post('temporary-password/online/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS.ADD_ONLINE_TEMPORARY_PASSWORD_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.ADD_ONLINE_TEMPORARY_PASSWORD_DESCRIPTION,
})
async addOnlineTemporaryPassword( async addOnlineTemporaryPassword(
@Body() addDoorLockDto: AddDoorLockOnlineDto, @Body() addDoorLockDto: AddDoorLockOnlineDto,
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
@ -40,15 +48,24 @@ export class DoorLockController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'online temporary password added successfully', message: 'Online temporary password added successfully',
data: { data: {
id: temporaryPassword.id, id: temporaryPassword.id,
}, },
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/offline/one-time/:doorLockUuid') @Post('temporary-password/offline/one-time/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.ADD_OFFLINE_ONE_TIME_TEMPORARY_PASSWORD_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.ADD_OFFLINE_ONE_TIME_TEMPORARY_PASSWORD_DESCRIPTION,
})
async addOfflineOneTimeTemporaryPassword( async addOfflineOneTimeTemporaryPassword(
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
) { ) {
@ -60,13 +77,22 @@ export class DoorLockController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'offline temporary password added successfully', message: 'Offline one-time temporary password added successfully',
data: temporaryPassword, data: temporaryPassword,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/offline/multiple-time/:doorLockUuid') @Post('temporary-password/offline/multiple-time/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.ADD_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORD_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.ADD_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORD_DESCRIPTION,
})
async addOfflineMultipleTimeTemporaryPassword( async addOfflineMultipleTimeTemporaryPassword(
@Body() @Body()
addDoorLockOfflineTempMultipleTimeDto: AddDoorLockOfflineTempMultipleTimeDto, addDoorLockOfflineTempMultipleTimeDto: AddDoorLockOfflineTempMultipleTimeDto,
@ -81,13 +107,21 @@ export class DoorLockController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'offline temporary password added successfully', message: 'Offline multiple-time temporary password added successfully',
data: temporaryPassword, data: temporaryPassword,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('temporary-password/online/:doorLockUuid') @Get('temporary-password/online/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS.GET_ONLINE_TEMPORARY_PASSWORDS_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.GET_ONLINE_TEMPORARY_PASSWORDS_DESCRIPTION,
})
async getOnlineTemporaryPasswords( async getOnlineTemporaryPasswords(
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
) { ) {
@ -95,9 +129,18 @@ export class DoorLockController {
doorLockUuid, doorLockUuid,
); );
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Delete('temporary-password/online/:doorLockUuid/:passwordId') @Delete('temporary-password/online/:doorLockUuid/:passwordId')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.DELETE_ONLINE_TEMPORARY_PASSWORD_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.DELETE_ONLINE_TEMPORARY_PASSWORD_DESCRIPTION,
})
async deleteDoorLockPassword( async deleteDoorLockPassword(
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
@Param('passwordId') passwordId: string, @Param('passwordId') passwordId: string,
@ -105,12 +148,21 @@ export class DoorLockController {
await this.doorLockService.deleteDoorLockPassword(doorLockUuid, passwordId); await this.doorLockService.deleteDoorLockPassword(doorLockUuid, passwordId);
return { return {
statusCode: HttpStatus.OK, statusCode: HttpStatus.OK,
message: 'Temporary Password deleted Successfully', message: 'Temporary password deleted successfully',
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('temporary-password/offline/one-time/:doorLockUuid') @Get('temporary-password/offline/one-time/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.GET_OFFLINE_ONE_TIME_TEMPORARY_PASSWORDS_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.GET_OFFLINE_ONE_TIME_TEMPORARY_PASSWORDS_DESCRIPTION,
})
async getOfflineOneTimeTemporaryPasswords( async getOfflineOneTimeTemporaryPasswords(
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
) { ) {
@ -118,9 +170,18 @@ export class DoorLockController {
doorLockUuid, doorLockUuid,
); );
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('temporary-password/offline/multiple-time/:doorLockUuid') @Get('temporary-password/offline/multiple-time/:doorLockUuid')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.GET_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORDS_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.GET_OFFLINE_MULTIPLE_TIME_TEMPORARY_PASSWORDS_DESCRIPTION,
})
async getOfflineMultipleTimeTemporaryPasswords( async getOfflineMultipleTimeTemporaryPasswords(
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
) { ) {
@ -132,9 +193,16 @@ export class DoorLockController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('temporary-password/:doorLockUuid/offline/:passwordId') @Put('temporary-password/:doorLockUuid/offline/:passwordId')
@ApiOperation({
summary:
ControllerRoute.DOOR_LOCK.ACTIONS
.UPDATE_OFFLINE_TEMPORARY_PASSWORD_SUMMARY,
description:
ControllerRoute.DOOR_LOCK.ACTIONS
.UPDATE_OFFLINE_TEMPORARY_PASSWORD_DESCRIPTION,
})
async updateOfflineTemporaryPassword( async updateOfflineTemporaryPassword(
@Body() @Body() updateDoorLockOfflineTempDto: UpdateDoorLockOfflineTempDto,
updateDoorLockOfflineTempDto: UpdateDoorLockOfflineTempDto,
@Param('doorLockUuid') doorLockUuid: string, @Param('doorLockUuid') doorLockUuid: string,
@Param('passwordId') passwordId: string, @Param('passwordId') passwordId: string,
) { ) {
@ -148,20 +216,25 @@ export class DoorLockController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'offline temporary password updated successfully', message: 'Offline temporary password updated successfully',
data: temporaryPassword, data: temporaryPassword,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('open/:doorLockUuid') @Post('open/:doorLockUuid')
@ApiOperation({
summary: ControllerRoute.DOOR_LOCK.ACTIONS.OPEN_DOOR_LOCK_SUMMARY,
description: ControllerRoute.DOOR_LOCK.ACTIONS.OPEN_DOOR_LOCK_DESCRIPTION,
})
async openDoorLock(@Param('doorLockUuid') doorLockUuid: string) { async openDoorLock(@Param('doorLockUuid') doorLockUuid: string) {
await this.doorLockService.openDoorLock(doorLockUuid); await this.doorLockService.openDoorLock(doorLockUuid);
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'door lock opened successfully', message: 'Door lock opened successfully',
}; };
} }
} }

View File

@ -1,13 +1,14 @@
import { GroupService } from '../services/group.service'; import { GroupService } from '../services/group.service';
import { Controller, Get, UseGuards, Param, Req } from '@nestjs/common'; import { Controller, Get, UseGuards, Param, Req } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined
@ApiTags('Group Module') @ApiTags('Group Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'group', path: ControllerRoute.GROUP.ROUTE, // use the static route constant
}) })
export class GroupController { export class GroupController {
constructor(private readonly groupService: GroupService) {} constructor(private readonly groupService: GroupService) {}
@ -15,6 +16,11 @@ export class GroupController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':spaceUuid') @Get(':spaceUuid')
@ApiOperation({
summary: ControllerRoute.GROUP.ACTIONS.GET_GROUPS_BY_SPACE_UUID_SUMMARY,
description:
ControllerRoute.GROUP.ACTIONS.GET_GROUPS_BY_SPACE_UUID_DESCRIPTION,
})
async getGroupsBySpaceUuid(@Param('spaceUuid') spaceUuid: string) { async getGroupsBySpaceUuid(@Param('spaceUuid') spaceUuid: string) {
return await this.groupService.getGroupsBySpaceUuid(spaceUuid); return await this.groupService.getGroupsBySpaceUuid(spaceUuid);
} }
@ -22,6 +28,12 @@ export class GroupController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':spaceUuid/devices/:groupName') @Get(':spaceUuid/devices/:groupName')
@ApiOperation({
summary:
ControllerRoute.GROUP.ACTIONS.GET_UNIT_DEVICES_BY_GROUP_NAME_SUMMARY,
description:
ControllerRoute.GROUP.ACTIONS.GET_UNIT_DEVICES_BY_GROUP_NAME_DESCRIPTION,
})
async getUnitDevicesByGroupName( async getUnitDevicesByGroupName(
@Param('spaceUuid') spaceUuid: string, @Param('spaceUuid') spaceUuid: string,
@Param('groupName') groupName: string, @Param('groupName') groupName: string,

View File

@ -6,22 +6,28 @@ import {
Post, Post,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { RoleService } from '../services/role.service'; import { RoleService } from '../services/role.service';
import { AddUserRoleDto } from '../dtos'; import { AddUserRoleDto } from '../dtos';
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard'; import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined
@ApiTags('Role Module') @ApiTags('Role Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'role', path: ControllerRoute.ROLE.ROUTE, // use the static route constant
}) })
export class RoleController { export class RoleController {
constructor(private readonly roleService: RoleService) {} constructor(private readonly roleService: RoleService) {}
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard) @UseGuards(SuperAdminRoleGuard)
@Get('types') @Get('types')
@ApiOperation({
summary: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_SUMMARY,
description: ControllerRoute.ROLE.ACTIONS.FETCH_ROLE_TYPES_DESCRIPTION,
})
async fetchRoleTypes() { async fetchRoleTypes() {
const roleTypes = await this.roleService.fetchRoleTypes(); const roleTypes = await this.roleService.fetchRoleTypes();
return { return {
@ -30,9 +36,14 @@ export class RoleController {
data: roleTypes, data: roleTypes,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard) @UseGuards(SuperAdminRoleGuard)
@Post() @Post()
@ApiOperation({
summary: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_SUMMARY,
description: ControllerRoute.ROLE.ACTIONS.ADD_USER_ROLE_DESCRIPTION,
})
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) { async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
await this.roleService.addUserRoleType(addUserRoleDto); await this.roleService.addUserRoleType(addUserRoleDto);
return { return {

View File

@ -459,6 +459,7 @@ export class SceneService {
const space = await this.getSpaceByUuid(scene.spaceUuid); const space = await this.getSpaceByUuid(scene.spaceUuid);
await this.delete(scene.sceneTuyaUuid, space.spaceTuyaUuid); await this.delete(scene.sceneTuyaUuid, space.spaceTuyaUuid);
await this.sceneRepository.delete({ uuid: sceneUuid });
return new SuccessResponseDto({ return new SuccessResponseDto({
message: `Scene with ID ${sceneUuid} deleted successfully`, message: `Scene with ID ${sceneUuid} deleted successfully`,
}); });

View File

@ -11,7 +11,7 @@ import {
Delete, Delete,
Query, Query,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { import {
AddScheduleDto, AddScheduleDto,
EnableScheduleDto, EnableScheduleDto,
@ -21,17 +21,24 @@ import {
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Schedule Module') @ApiTags('Schedule Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'schedule', path: ControllerRoute.SCHEDULE.ROUTE,
}) })
export class ScheduleController { export class ScheduleController {
constructor(private readonly scheduleService: ScheduleService) {} constructor(private readonly scheduleService: ScheduleService) {}
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post(':deviceUuid') @Post(':deviceUuid')
@ApiOperation({
summary: ControllerRoute.SCHEDULE.ACTIONS.ADD_DEVICE_SCHEDULE_SUMMARY,
description:
ControllerRoute.SCHEDULE.ACTIONS.ADD_DEVICE_SCHEDULE_DESCRIPTION,
})
async addDeviceSchedule( async addDeviceSchedule(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Body() addScheduleDto: AddScheduleDto, @Body() addScheduleDto: AddScheduleDto,
@ -44,13 +51,21 @@ export class ScheduleController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'schedule added successfully', message: 'Schedule added successfully',
data: schedule, data: schedule,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':deviceUuid') @Get(':deviceUuid')
@ApiOperation({
summary:
ControllerRoute.SCHEDULE.ACTIONS.GET_DEVICE_SCHEDULE_BY_CATEGORY_SUMMARY,
description:
ControllerRoute.SCHEDULE.ACTIONS
.GET_DEVICE_SCHEDULE_BY_CATEGORY_DESCRIPTION,
})
async getDeviceScheduleByCategory( async getDeviceScheduleByCategory(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Query() query: GetScheduleDeviceDto, @Query() query: GetScheduleDeviceDto,
@ -60,9 +75,15 @@ export class ScheduleController {
query.category, query.category,
); );
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Delete(':deviceUuid/:scheduleId') @Delete(':deviceUuid/:scheduleId')
@ApiOperation({
summary: ControllerRoute.SCHEDULE.ACTIONS.DELETE_DEVICE_SCHEDULE_SUMMARY,
description:
ControllerRoute.SCHEDULE.ACTIONS.DELETE_DEVICE_SCHEDULE_DESCRIPTION,
})
async deleteDeviceSchedule( async deleteDeviceSchedule(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Param('scheduleId') scheduleId: string, @Param('scheduleId') scheduleId: string,
@ -71,12 +92,18 @@ export class ScheduleController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'schedule deleted successfully', message: 'Schedule deleted successfully',
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('enable/:deviceUuid') @Put('enable/:deviceUuid')
@ApiOperation({
summary: ControllerRoute.SCHEDULE.ACTIONS.ENABLE_DEVICE_SCHEDULE_SUMMARY,
description:
ControllerRoute.SCHEDULE.ACTIONS.ENABLE_DEVICE_SCHEDULE_DESCRIPTION,
})
async enableDeviceSchedule( async enableDeviceSchedule(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Body() enableScheduleDto: EnableScheduleDto, @Body() enableScheduleDto: EnableScheduleDto,
@ -88,12 +115,18 @@ export class ScheduleController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'schedule updated successfully', message: 'Schedule updated successfully',
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put(':deviceUuid') @Put(':deviceUuid')
@ApiOperation({
summary: ControllerRoute.SCHEDULE.ACTIONS.UPDATE_DEVICE_SCHEDULE_SUMMARY,
description:
ControllerRoute.SCHEDULE.ACTIONS.UPDATE_DEVICE_SCHEDULE_DESCRIPTION,
})
async updateDeviceSchedule( async updateDeviceSchedule(
@Param('deviceUuid') deviceUuid: string, @Param('deviceUuid') deviceUuid: string,
@Body() updateScheduleDto: UpdateScheduleDto, @Body() updateScheduleDto: UpdateScheduleDto,
@ -106,7 +139,7 @@ export class ScheduleController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'schedule updated successfully', message: 'Schedule updated successfully',
data: schedule, data: schedule,
}; };
} }

View File

@ -26,8 +26,8 @@ export class SpaceDeviceService {
spaceUuid, spaceUuid,
); );
const detailedDevices = await Promise.all( const safeFetch = async (device: any) => {
space.devices.map(async (device) => { try {
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya( const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
device.deviceTuyaUuid, device.deviceTuyaUuid,
); );
@ -41,11 +41,18 @@ export class SpaceDeviceService {
updatedAt: device.updatedAt, updatedAt: device.updatedAt,
...tuyaDetails, ...tuyaDetails,
}; };
}), } catch (error) {
); console.warn(
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
);
return null;
}
};
const detailedDevices = await Promise.all(space.devices.map(safeFetch));
return new SuccessResponseDto({ return new SuccessResponseDto({
data: detailedDevices, data: detailedDevices.filter(Boolean), // Remove null or undefined values
message: 'Successfully retrieved list of devices', message: 'Successfully retrieved list of devices',
}); });
} catch (error) { } catch (error) {

View File

@ -33,8 +33,8 @@ export class SubspaceDeviceService {
const subspace = await this.findSubspaceWithDevices(subSpaceUuid); const subspace = await this.findSubspaceWithDevices(subSpaceUuid);
const detailedDevices = await Promise.all( const safeFetch = async (device: any) => {
subspace.devices.map(async (device) => { try {
const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya( const tuyaDetails = await this.getDeviceDetailsByDeviceIdTuya(
device.deviceTuyaUuid, device.deviceTuyaUuid,
); );
@ -49,11 +49,17 @@ export class SubspaceDeviceService {
updatedAt: device.updatedAt, updatedAt: device.updatedAt,
...tuyaDetails, ...tuyaDetails,
}; };
}), } catch (error) {
); console.warn(
`Skipping device with deviceTuyaUuid: ${device.deviceTuyaUuid} due to error.`,
);
return null;
}
};
const detailedDevices = await Promise.all(subspace.devices.map(safeFetch));
return new SuccessResponseDto({ return new SuccessResponseDto({
data: detailedDevices, data: detailedDevices.filter(Boolean), // Remove nulls
message: 'Successfully retrieved list of devices', message: 'Successfully retrieved list of devices',
}); });
} }

View File

@ -1,13 +1,14 @@
import { Controller, Get, UseGuards } from '@nestjs/common'; import { Controller, Get, UseGuards } from '@nestjs/common';
import { TimeZoneService } from '../services/timezone.service'; import { TimeZoneService } from '../services/timezone.service';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard'; import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('TimeZone Module') @ApiTags('TimeZone Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'timezone', path: ControllerRoute.TIMEZONE.ROUTE,
}) })
export class TimeZoneController { export class TimeZoneController {
constructor(private readonly timeZoneService: TimeZoneService) {} constructor(private readonly timeZoneService: TimeZoneService) {}
@ -15,6 +16,11 @@ export class TimeZoneController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get() @Get()
@ApiOperation({
summary: ControllerRoute.TIMEZONE.ACTIONS.GET_ALL_TIME_ZONES_SUMMARY,
description:
ControllerRoute.TIMEZONE.ACTIONS.GET_ALL_TIME_ZONES_DESCRIPTION,
})
async getAllTimeZones() { async getAllTimeZones() {
return await this.timeZoneService.getAllTimeZones(); return await this.timeZoneService.getAllTimeZones();
} }

View File

@ -9,17 +9,18 @@ import {
Put, Put,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiTags, ApiOperation } from '@nestjs/swagger';
import { UserDevicePermissionService } from '../services/user-device-permission.service'; import { UserDevicePermissionService } from '../services/user-device-permission.service';
import { UserDevicePermissionAddDto } from '../dtos/user-device-permission.add.dto'; import { UserDevicePermissionAddDto } from '../dtos/user-device-permission.add.dto';
import { UserDevicePermissionEditDto } from '../dtos/user-device-permission.edit.dto'; import { UserDevicePermissionEditDto } from '../dtos/user-device-permission.edit.dto';
import { AdminRoleGuard } from 'src/guards/admin.role.guard'; import { AdminRoleGuard } from 'src/guards/admin.role.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Device Permission Module') @ApiTags('Device Permission Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'device-permission', path: ControllerRoute.DEVICE_PERMISSION.ROUTE,
}) })
export class UserDevicePermissionController { export class UserDevicePermissionController {
constructor( constructor(
@ -29,6 +30,11 @@ export class UserDevicePermissionController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(AdminRoleGuard) @UseGuards(AdminRoleGuard)
@Post() @Post()
@ApiOperation({
summary: ControllerRoute.DEVICE_PERMISSION.ACTIONS.ADD_PERMISSION_SUMMARY,
description:
ControllerRoute.DEVICE_PERMISSION.ACTIONS.ADD_PERMISSION_DESCRIPTION,
})
async addDevicePermission( async addDevicePermission(
@Body() userDevicePermissionDto: UserDevicePermissionAddDto, @Body() userDevicePermissionDto: UserDevicePermissionAddDto,
) { ) {
@ -45,6 +51,11 @@ export class UserDevicePermissionController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(AdminRoleGuard) @UseGuards(AdminRoleGuard)
@Put(':devicePermissionUuid') @Put(':devicePermissionUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE_PERMISSION.ACTIONS.EDIT_PERMISSION_SUMMARY,
description:
ControllerRoute.DEVICE_PERMISSION.ACTIONS.EDIT_PERMISSION_DESCRIPTION,
})
async editDevicePermission( async editDevicePermission(
@Param('devicePermissionUuid') devicePermissionUuid: string, @Param('devicePermissionUuid') devicePermissionUuid: string,
@Body() userDevicePermissionEditDto: UserDevicePermissionEditDto, @Body() userDevicePermissionEditDto: UserDevicePermissionEditDto,
@ -62,6 +73,11 @@ export class UserDevicePermissionController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(AdminRoleGuard) @UseGuards(AdminRoleGuard)
@Get(':deviceUuid') @Get(':deviceUuid')
@ApiOperation({
summary: ControllerRoute.DEVICE_PERMISSION.ACTIONS.FETCH_PERMISSION_SUMMARY,
description:
ControllerRoute.DEVICE_PERMISSION.ACTIONS.FETCH_PERMISSION_DESCRIPTION,
})
async fetchDevicePermission(@Param('deviceUuid') deviceUuid: string) { async fetchDevicePermission(@Param('deviceUuid') deviceUuid: string) {
const deviceDetails = const deviceDetails =
await this.userDevicePermissionService.fetchUserPermission(deviceUuid); await this.userDevicePermissionService.fetchUserPermission(deviceUuid);
@ -71,9 +87,16 @@ export class UserDevicePermissionController {
data: deviceDetails, data: deviceDetails,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(AdminRoleGuard) @UseGuards(AdminRoleGuard)
@Delete(':devicePermissionUuid') @Delete(':devicePermissionUuid')
@ApiOperation({
summary:
ControllerRoute.DEVICE_PERMISSION.ACTIONS.DELETE_PERMISSION_SUMMARY,
description:
ControllerRoute.DEVICE_PERMISSION.ACTIONS.DELETE_PERMISSION_DESCRIPTION,
})
async deleteDevicePermission( async deleteDevicePermission(
@Param('devicePermissionUuid') devicePermissionUuid: string, @Param('devicePermissionUuid') devicePermissionUuid: string,
) { ) {

View File

@ -8,7 +8,7 @@ import {
Put, Put,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { ApiBearerAuth, ApiTags, ApiOperation } from '@nestjs/swagger';
import { UserNotificationService } from '../services/user-notification.service'; import { UserNotificationService } from '../services/user-notification.service';
import { import {
UserNotificationAddDto, UserNotificationAddDto,
@ -17,11 +17,12 @@ import {
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('User Notification Module') @ApiTags('User Notification Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'user-notification/subscription', path: ControllerRoute.USER_NOTIFICATION.ROUTE,
}) })
export class UserNotificationController { export class UserNotificationController {
constructor( constructor(
@ -31,6 +32,11 @@ export class UserNotificationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post() @Post()
@ApiOperation({
summary: ControllerRoute.USER_NOTIFICATION.ACTIONS.ADD_SUBSCRIPTION_SUMMARY,
description:
ControllerRoute.USER_NOTIFICATION.ACTIONS.ADD_SUBSCRIPTION_DESCRIPTION,
})
async addUserSubscription( async addUserSubscription(
@Body() userNotificationAddDto: UserNotificationAddDto, @Body() userNotificationAddDto: UserNotificationAddDto,
) { ) {
@ -47,6 +53,12 @@ export class UserNotificationController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':userUuid') @Get(':userUuid')
@ApiOperation({
summary:
ControllerRoute.USER_NOTIFICATION.ACTIONS.FETCH_SUBSCRIPTIONS_SUMMARY,
description:
ControllerRoute.USER_NOTIFICATION.ACTIONS.FETCH_SUBSCRIPTIONS_DESCRIPTION,
})
async fetchUserSubscriptions(@Param('userUuid') userUuid: string) { async fetchUserSubscriptions(@Param('userUuid') userUuid: string) {
const userDetails = const userDetails =
await this.userNotificationService.fetchUserSubscriptions(userUuid); await this.userNotificationService.fetchUserSubscriptions(userUuid);
@ -56,9 +68,16 @@ export class UserNotificationController {
data: { ...userDetails }, data: { ...userDetails },
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put() @Put()
@ApiOperation({
summary:
ControllerRoute.USER_NOTIFICATION.ACTIONS.UPDATE_SUBSCRIPTION_SUMMARY,
description:
ControllerRoute.USER_NOTIFICATION.ACTIONS.UPDATE_SUBSCRIPTION_DESCRIPTION,
})
async updateUserSubscription( async updateUserSubscription(
@Body() userNotificationUpdateDto: UserNotificationUpdateDto, @Body() userNotificationUpdateDto: UserNotificationUpdateDto,
) { ) {

View File

@ -40,6 +40,13 @@ export class UserSpaceController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/verify-code') @Post('/verify-code')
@ApiOperation({
summary:
ControllerRoute.USER_SPACE.ACTIONS.VERIFY_CODE_AND_ADD_USER_SPACE_SUMMARY,
description:
ControllerRoute.USER_SPACE.ACTIONS
.VERIFY_CODE_AND_ADD_USER_SPACE_DESCRIPTION,
})
async verifyCodeAndAddUserSpace( async verifyCodeAndAddUserSpace(
@Body() dto: AddUserSpaceUsingCodeDto, @Body() dto: AddUserSpaceUsingCodeDto,
@Param() params: UserParamDto, @Param() params: UserParamDto,

View File

@ -9,7 +9,7 @@ import {
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { UserService } from '../services/user.service'; import { UserService } from '../services/user.service';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard'; import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
import { import {
UpdateNameDto, UpdateNameDto,
@ -20,11 +20,12 @@ import {
import { CheckProfilePictureGuard } from 'src/guards/profile.picture.guard'; import { CheckProfilePictureGuard } from 'src/guards/profile.picture.guard';
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard'; import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('User Module') @ApiTags('User Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'user', path: ControllerRoute.USER.ROUTE,
}) })
export class UserController { export class UserController {
constructor(private readonly userService: UserService) {} constructor(private readonly userService: UserService) {}
@ -32,12 +33,22 @@ export class UserController {
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get(':userUuid') @Get(':userUuid')
@ApiOperation({
summary: ControllerRoute.USER.ACTIONS.GET_USER_DETAILS_SUMMARY,
description: ControllerRoute.USER.ACTIONS.GET_USER_DETAILS_DESCRIPTION,
})
async getUserDetailsByUserUuid(@Param('userUuid') userUuid: string) { async getUserDetailsByUserUuid(@Param('userUuid') userUuid: string) {
return await this.userService.getUserDetailsByUserUuid(userUuid); return await this.userService.getUserDetailsByUserUuid(userUuid);
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard, CheckProfilePictureGuard) @UseGuards(JwtAuthGuard, CheckProfilePictureGuard)
@Put('/profile-picture/:userUuid') @Put('/profile-picture/:userUuid')
@ApiOperation({
summary: ControllerRoute.USER.ACTIONS.UPDATE_PROFILE_PICTURE_SUMMARY,
description:
ControllerRoute.USER.ACTIONS.UPDATE_PROFILE_PICTURE_DESCRIPTION,
})
async updateProfilePictureByUserUuid( async updateProfilePictureByUserUuid(
@Param('userUuid') userUuid: string, @Param('userUuid') userUuid: string,
@Body() updateProfilePictureDataDto: UpdateProfilePictureDataDto, @Body() updateProfilePictureDataDto: UpdateProfilePictureDataDto,
@ -49,13 +60,18 @@ export class UserController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'profile picture updated successfully', message: 'Profile picture updated successfully',
data: userData, data: userData,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('/region/:userUuid') @Put('/region/:userUuid')
@ApiOperation({
summary: ControllerRoute.USER.ACTIONS.UPDATE_REGION_SUMMARY,
description: ControllerRoute.USER.ACTIONS.UPDATE_REGION_DESCRIPTION,
})
async updateRegionByUserUuid( async updateRegionByUserUuid(
@Param('userUuid') userUuid: string, @Param('userUuid') userUuid: string,
@Body() updateRegionDataDto: UpdateRegionDataDto, @Body() updateRegionDataDto: UpdateRegionDataDto,
@ -67,14 +83,19 @@ export class UserController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'region updated successfully', message: 'Region updated successfully',
data: userData, data: userData,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('/timezone/:userUuid') @Put('/timezone/:userUuid')
async updateNameByUserUuid( @ApiOperation({
summary: ControllerRoute.USER.ACTIONS.UPDATE_TIMEZONE_SUMMARY,
description: ControllerRoute.USER.ACTIONS.UPDATE_TIMEZONE_DESCRIPTION,
})
async updateTimezoneByUserUuid(
@Param('userUuid') userUuid: string, @Param('userUuid') userUuid: string,
@Body() updateTimezoneDataDto: UpdateTimezoneDataDto, @Body() updateTimezoneDataDto: UpdateTimezoneDataDto,
) { ) {
@ -85,14 +106,19 @@ export class UserController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'timezone updated successfully', message: 'Timezone updated successfully',
data: userData, data: userData,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Put('/name/:userUuid') @Put('/name/:userUuid')
async updateTimezoneByUserUuid( @ApiOperation({
summary: ControllerRoute.USER.ACTIONS.UPDATE_NAME_SUMMARY,
description: ControllerRoute.USER.ACTIONS.UPDATE_NAME_DESCRIPTION,
})
async updateNameByUserUuid(
@Param('userUuid') userUuid: string, @Param('userUuid') userUuid: string,
@Body() updateNameDto: UpdateNameDto, @Body() updateNameDto: UpdateNameDto,
) { ) {
@ -103,13 +129,18 @@ export class UserController {
return { return {
statusCode: HttpStatus.CREATED, statusCode: HttpStatus.CREATED,
success: true, success: true,
message: 'name updated successfully', message: 'Name updated successfully',
data: userData, data: userData,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard) @UseGuards(SuperAdminRoleGuard)
@Delete('/:userUuid') @Delete('/:userUuid')
@ApiOperation({
summary: ControllerRoute.USER.ACTIONS.DELETE_USER_SUMMARY,
description: ControllerRoute.USER.ACTIONS.DELETE_USER_DESCRIPTION,
})
async userDelete(@Param('userUuid') userUuid: string) { async userDelete(@Param('userUuid') userUuid: string) {
await this.userService.deleteUser(userUuid); await this.userService.deleteUser(userUuid);
return { return {
@ -117,7 +148,7 @@ export class UserController {
data: { data: {
userUuid, userUuid,
}, },
message: 'User Deleted Successfully', message: 'User deleted successfully',
}; };
} }
} }

View File

@ -8,7 +8,7 @@ import {
Get, Get,
Req, Req,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { import {
AddDoorLockOfflineMultipleDto, AddDoorLockOfflineMultipleDto,
AddDoorLockOfflineOneTimeDto, AddDoorLockOfflineOneTimeDto,
@ -17,19 +17,29 @@ import {
} from '../dtos/temp-pass.dto'; } from '../dtos/temp-pass.dto';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard'; import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum'; import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route';
@ApiTags('Visitor Password Module') @ApiTags('Visitor Password Module')
@Controller({ @Controller({
version: EnableDisableStatusEnum.ENABLED, version: EnableDisableStatusEnum.ENABLED,
path: 'visitor-password', path: ControllerRoute.VISITOR_PASSWORD.ROUTE,
}) })
export class VisitorPasswordController { export class VisitorPasswordController {
constructor( constructor(
private readonly visitorPasswordService: VisitorPasswordService, private readonly visitorPasswordService: VisitorPasswordService,
) {} ) {}
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/online/multiple-time') @Post('temporary-password/online/multiple-time')
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_ONLINE_TEMP_PASSWORD_MULTIPLE_TIME_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_ONLINE_TEMP_PASSWORD_MULTIPLE_TIME_DESCRIPTION,
})
async addOnlineTemporaryPasswordMultipleTime( async addOnlineTemporaryPasswordMultipleTime(
@Body() addDoorLockOnlineMultipleDto: AddDoorLockOnlineMultipleDto, @Body() addDoorLockOnlineMultipleDto: AddDoorLockOnlineMultipleDto,
@Req() req: any, @Req() req: any,
@ -46,9 +56,18 @@ export class VisitorPasswordController {
data: temporaryPasswords, data: temporaryPasswords,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/online/one-time') @Post('temporary-password/online/one-time')
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_ONLINE_TEMP_PASSWORD_ONE_TIME_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_ONLINE_TEMP_PASSWORD_ONE_TIME_DESCRIPTION,
})
async addOnlineTemporaryPassword( async addOnlineTemporaryPassword(
@Body() addDoorLockOnlineOneTimeDto: AddDoorLockOnlineOneTimeDto, @Body() addDoorLockOnlineOneTimeDto: AddDoorLockOnlineOneTimeDto,
@Req() req: any, @Req() req: any,
@ -65,9 +84,18 @@ export class VisitorPasswordController {
data: temporaryPasswords, data: temporaryPasswords,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/offline/one-time') @Post('temporary-password/offline/one-time')
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_OFFLINE_TEMP_PASSWORD_ONE_TIME_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_OFFLINE_TEMP_PASSWORD_ONE_TIME_DESCRIPTION,
})
async addOfflineOneTimeTemporaryPassword( async addOfflineOneTimeTemporaryPassword(
@Body() addDoorLockOfflineOneTimeDto: AddDoorLockOfflineOneTimeDto, @Body() addDoorLockOfflineOneTimeDto: AddDoorLockOfflineOneTimeDto,
@Req() req: any, @Req() req: any,
@ -84,9 +112,18 @@ export class VisitorPasswordController {
data: temporaryPassword, data: temporaryPassword,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('temporary-password/offline/multiple-time') @Post('temporary-password/offline/multiple-time')
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_OFFLINE_TEMP_PASSWORD_MULTIPLE_TIME_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS
.ADD_OFFLINE_TEMP_PASSWORD_MULTIPLE_TIME_DESCRIPTION,
})
async addOfflineMultipleTimeTemporaryPassword( async addOfflineMultipleTimeTemporaryPassword(
@Body() @Body()
addDoorLockOfflineMultipleDto: AddDoorLockOfflineMultipleDto, addDoorLockOfflineMultipleDto: AddDoorLockOfflineMultipleDto,
@ -104,15 +141,29 @@ export class VisitorPasswordController {
data: temporaryPassword, data: temporaryPassword,
}; };
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get() @Get()
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS.GET_VISITOR_PASSWORD_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS.GET_VISITOR_PASSWORD_DESCRIPTION,
})
async GetVisitorPassword() { async GetVisitorPassword() {
return await this.visitorPasswordService.getPasswords(); return await this.visitorPasswordService.getPasswords();
} }
@ApiBearerAuth() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('/devices') @Get('/devices')
@ApiOperation({
summary:
ControllerRoute.VISITOR_PASSWORD.ACTIONS.GET_VISITOR_DEVICES_SUMMARY,
description:
ControllerRoute.VISITOR_PASSWORD.ACTIONS.GET_VISITOR_DEVICES_DESCRIPTION,
})
async GetVisitorDevices() { async GetVisitorDevices() {
return await this.visitorPasswordService.getAllPassDevices(); return await this.visitorPasswordService.getAllPassDevices();
} }