mirror of
https://github.com/immich-app/immich.git
synced 2025-06-06 07:04:26 -04:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
import {
|
|
AssetFaceCreateDto,
|
|
AssetFaceDeleteDto,
|
|
AssetFaceResponseDto,
|
|
FaceDto,
|
|
PersonResponseDto,
|
|
} from 'src/dtos/person.dto';
|
|
import { Permission } from 'src/enum';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { PersonService } from 'src/services/person.service';
|
|
import { UUIDParamDto } from 'src/validation';
|
|
|
|
@ApiTags('Faces')
|
|
@Controller('faces')
|
|
export class FaceController {
|
|
constructor(private service: PersonService) {}
|
|
|
|
@Post()
|
|
@Authenticated({ permission: Permission.FACE_CREATE })
|
|
createFace(@Auth() auth: AuthDto, @Body() dto: AssetFaceCreateDto) {
|
|
return this.service.createFace(auth, dto);
|
|
}
|
|
|
|
@Get()
|
|
@Authenticated({ permission: Permission.FACE_READ })
|
|
getFaces(@Auth() auth: AuthDto, @Query() dto: FaceDto): Promise<AssetFaceResponseDto[]> {
|
|
return this.service.getFacesById(auth, dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@Authenticated({ permission: Permission.FACE_UPDATE })
|
|
reassignFacesById(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: FaceDto,
|
|
): Promise<PersonResponseDto> {
|
|
return this.service.reassignFacesById(auth, id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@Authenticated({ permission: Permission.FACE_DELETE })
|
|
deleteFace(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Body() dto: AssetFaceDeleteDto) {
|
|
return this.service.deleteFace(auth, id, dto);
|
|
}
|
|
}
|