mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 10:24:53 +00:00
Add Visitor Password Management Module
This commit is contained in:
125
src/vistor-password/controllers/visitor-password.controller.ts
Normal file
125
src/vistor-password/controllers/visitor-password.controller.ts
Normal file
@ -0,0 +1,125 @@
|
||||
import { VisitorPasswordService } from '../services/visitor-password.service';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Post,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import {
|
||||
AddDoorLockOfflineMultipleDto,
|
||||
AddDoorLockOfflineOneTimeDto,
|
||||
AddDoorLockOnlineMultipleDto,
|
||||
AddDoorLockOnlineOneTimeDto,
|
||||
} from '../dtos/temp-pass.dto';
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
|
||||
@ApiTags('Visitor Password Module')
|
||||
@Controller({
|
||||
version: '1',
|
||||
path: 'visitor-password',
|
||||
})
|
||||
export class VisitorPasswordController {
|
||||
constructor(
|
||||
private readonly visitorPasswordService: VisitorPasswordService,
|
||||
) {}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('temporary-password/online/multiple-time')
|
||||
async addOnlineTemporaryPasswordMultipleTime(
|
||||
@Body() addDoorLockOnlineMultipleDto: AddDoorLockOnlineMultipleDto,
|
||||
) {
|
||||
try {
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordMultipleTime(
|
||||
addDoorLockOnlineMultipleDto,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('temporary-password/online/one-time')
|
||||
async addOnlineTemporaryPassword(
|
||||
@Body() addDoorLockOnlineOneTimeDto: AddDoorLockOnlineOneTimeDto,
|
||||
) {
|
||||
try {
|
||||
const temporaryPasswords =
|
||||
await this.visitorPasswordService.addOnlineTemporaryPasswordOneTime(
|
||||
addDoorLockOnlineOneTimeDto,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
data: temporaryPasswords,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('temporary-password/offline/one-time')
|
||||
async addOfflineOneTimeTemporaryPassword(
|
||||
@Body() addDoorLockOfflineOneTimeDto: AddDoorLockOfflineOneTimeDto,
|
||||
) {
|
||||
try {
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineOneTimeTemporaryPassword(
|
||||
addDoorLockOfflineOneTimeDto,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'offline temporary password added successfully',
|
||||
data: temporaryPassword,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('temporary-password/offline/multiple-time')
|
||||
async addOfflineMultipleTimeTemporaryPassword(
|
||||
@Body()
|
||||
addDoorLockOfflineMultipleDto: AddDoorLockOfflineMultipleDto,
|
||||
) {
|
||||
try {
|
||||
const temporaryPassword =
|
||||
await this.visitorPasswordService.addOfflineMultipleTimeTemporaryPassword(
|
||||
addDoorLockOfflineMultipleDto,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'offline temporary password added successfully',
|
||||
data: temporaryPassword,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user