Initial commit: digital reception monorepo (M1-M11 + demo extensions)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
||||
import { Role } from '@reception/db';
|
||||
import { Roles } from '../auth/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../auth/guards/roles.guard';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
@UseGuards(RolesGuard)
|
||||
@Controller('audit')
|
||||
export class AuditController {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
@Roles(Role.SYSADMIN)
|
||||
@Get('biometry')
|
||||
async biometry(
|
||||
@Query('actorUserId') actorUserId?: string,
|
||||
@Query('subjectPatientId') subjectPatientId?: string,
|
||||
@Query('from') from?: string,
|
||||
@Query('to') to?: string,
|
||||
@Query('limit') limitRaw?: string,
|
||||
) {
|
||||
const take = Math.min(Number(limitRaw) || 100, 500);
|
||||
const where: Record<string, unknown> = {};
|
||||
if (actorUserId) where.actorUserId = actorUserId;
|
||||
if (subjectPatientId) where.subjectPatientId = subjectPatientId;
|
||||
if (from || to) {
|
||||
where.occurredAt = {} as Record<string, Date>;
|
||||
if (from) (where.occurredAt as Record<string, Date>).gte = new Date(from);
|
||||
if (to) (where.occurredAt as Record<string, Date>).lte = new Date(to);
|
||||
}
|
||||
|
||||
return this.prisma.biometryAccessLog.findMany({
|
||||
where,
|
||||
orderBy: { occurredAt: 'desc' },
|
||||
include: { actor: { select: { email: true, fullName: true, role: true } } },
|
||||
take,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuditController } from './audit.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [AuditController],
|
||||
})
|
||||
export class AuditModule {}
|
||||
Reference in New Issue
Block a user