2025-02-21 09:58:25 -06:00
|
|
|
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
|
2023-12-05 16:43:15 +01:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
2025-02-21 09:58:25 -06:00
|
|
|
import {
|
|
|
|
|
AssetFaceCreateDto,
|
|
|
|
|
AssetFaceDeleteDto,
|
|
|
|
|
AssetFaceResponseDto,
|
|
|
|
|
FaceDto,
|
|
|
|
|
PersonResponseDto,
|
|
|
|
|
} from 'src/dtos/person.dto';
|
2024-08-16 09:48:43 -04:00
|
|
|
import { Permission } from 'src/enum';
|
2024-03-20 15:15:01 -05:00
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { PersonService } from 'src/services/person.service';
|
2024-03-20 15:04:03 -05:00
|
|
|
import { UUIDParamDto } from 'src/validation';
|
2023-12-05 16:43:15 +01:00
|
|
|
|
2024-05-30 00:26:57 +02:00
|
|
|
@ApiTags('Faces')
|
2024-05-22 13:24:57 -04:00
|
|
|
@Controller('faces')
|
2023-12-05 16:43:15 +01:00
|
|
|
export class FaceController {
|
|
|
|
|
constructor(private service: PersonService) {}
|
|
|
|
|
|
2025-02-21 09:58:25 -06:00
|
|
|
@Post()
|
|
|
|
|
@Authenticated({ permission: Permission.FACE_CREATE })
|
|
|
|
|
createFace(@Auth() auth: AuthDto, @Body() dto: AssetFaceCreateDto) {
|
|
|
|
|
return this.service.createFace(auth, dto);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-05 16:43:15 +01:00
|
|
|
@Get()
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.FACE_READ })
|
2023-12-09 23:34:12 -05:00
|
|
|
getFaces(@Auth() auth: AuthDto, @Query() dto: FaceDto): Promise<AssetFaceResponseDto[]> {
|
|
|
|
|
return this.service.getFacesById(auth, dto);
|
2023-12-05 16:43:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Put(':id')
|
2024-08-16 09:48:43 -04:00
|
|
|
@Authenticated({ permission: Permission.FACE_UPDATE })
|
2023-12-05 16:43:15 +01:00
|
|
|
reassignFacesById(
|
2023-12-09 23:34:12 -05:00
|
|
|
@Auth() auth: AuthDto,
|
2023-12-05 16:43:15 +01:00
|
|
|
@Param() { id }: UUIDParamDto,
|
|
|
|
|
@Body() dto: FaceDto,
|
|
|
|
|
): Promise<PersonResponseDto> {
|
2023-12-09 23:34:12 -05:00
|
|
|
return this.service.reassignFacesById(auth, id, dto);
|
2023-12-05 16:43:15 +01:00
|
|
|
}
|
2025-02-21 09:58:25 -06:00
|
|
|
|
|
|
|
|
@Delete(':id')
|
|
|
|
|
@Authenticated({ permission: Permission.FACE_DELETE })
|
|
|
|
|
deleteFace(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Body() dto: AssetFaceDeleteDto) {
|
|
|
|
|
return this.service.deleteFace(auth, id, dto);
|
|
|
|
|
}
|
2023-12-05 16:43:15 +01:00
|
|
|
}
|