mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
added exception filter and removed controller error handling
This commit is contained in:
@ -3,7 +3,6 @@ import {
|
||||
Body,
|
||||
Controller,
|
||||
Post,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
UseGuards,
|
||||
Get,
|
||||
@ -34,24 +33,17 @@ export class VisitorPasswordController {
|
||||
@Body() addDoorLockOnlineMultipleDto: AddDoorLockOnlineMultipleDto,
|
||||
@Req() req: any,
|
||||
) {
|
||||
try {
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordMultipleTime(
|
||||
addDoorLockOnlineMultipleDto,
|
||||
userUuid,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordMultipleTime(
|
||||
addDoorLockOnlineMultipleDto,
|
||||
userUuid,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ -60,24 +52,17 @@ export class VisitorPasswordController {
|
||||
@Body() addDoorLockOnlineOneTimeDto: AddDoorLockOnlineOneTimeDto,
|
||||
@Req() req: any,
|
||||
) {
|
||||
try {
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordOneTime(
|
||||
addDoorLockOnlineOneTimeDto,
|
||||
userUuid,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordOneTime(
|
||||
addDoorLockOnlineOneTimeDto,
|
||||
userUuid,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ -86,24 +71,17 @@ export class VisitorPasswordController {
|
||||
@Body() addDoorLockOfflineOneTimeDto: AddDoorLockOfflineOneTimeDto,
|
||||
@Req() req: any,
|
||||
) {
|
||||
try {
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineOneTimeTemporaryPassword(
|
||||
addDoorLockOfflineOneTimeDto,
|
||||
userUuid,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPassword,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineOneTimeTemporaryPassword(
|
||||
addDoorLockOfflineOneTimeDto,
|
||||
userUuid,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPassword,
|
||||
};
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ -113,49 +91,28 @@ export class VisitorPasswordController {
|
||||
addDoorLockOfflineMultipleDto: AddDoorLockOfflineMultipleDto,
|
||||
@Req() req: any,
|
||||
) {
|
||||
try {
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineMultipleTimeTemporaryPassword(
|
||||
addDoorLockOfflineMultipleDto,
|
||||
userUuid,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPassword,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
const userUuid = req.user.uuid;
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineMultipleTimeTemporaryPassword(
|
||||
addDoorLockOfflineMultipleDto,
|
||||
userUuid,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPassword,
|
||||
};
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get()
|
||||
async GetVisitorPassword() {
|
||||
try {
|
||||
return await this.visitorPasswordService.getPasswords();
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
return await this.visitorPasswordService.getPasswords();
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/devices')
|
||||
async GetVisitorDevices() {
|
||||
try {
|
||||
return await this.visitorPasswordService.getAllPassDevices();
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
return await this.visitorPasswordService.getAllPassDevices();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user