mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
64 lines
1.9 KiB
TypeScript
64 lines
1.9 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 {
|
||
|
|
UserAdminCreateDto,
|
||
|
|
UserAdminDeleteDto,
|
||
|
|
UserAdminResponseDto,
|
||
|
|
UserAdminSearchDto,
|
||
|
|
UserAdminUpdateDto,
|
||
|
|
} from 'src/dtos/user.dto';
|
||
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
||
|
|
import { UserAdminService } from 'src/services/user-admin.service';
|
||
|
|
import { UUIDParamDto } from 'src/validation';
|
||
|
|
|
||
|
|
@ApiTags('User')
|
||
|
|
@Controller('admin/users')
|
||
|
|
export class UserAdminController {
|
||
|
|
constructor(private service: UserAdminService) {}
|
||
|
|
|
||
|
|
@Get()
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
searchUsersAdmin(@Auth() auth: AuthDto, @Query() dto: UserAdminSearchDto): Promise<UserAdminResponseDto[]> {
|
||
|
|
return this.service.search(auth, dto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post()
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
createUserAdmin(@Body() createUserDto: UserAdminCreateDto): Promise<UserAdminResponseDto> {
|
||
|
|
return this.service.create(createUserDto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Get(':id')
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
getUserAdmin(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<UserAdminResponseDto> {
|
||
|
|
return this.service.get(auth, id);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Put(':id')
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
updateUserAdmin(
|
||
|
|
@Auth() auth: AuthDto,
|
||
|
|
@Param() { id }: UUIDParamDto,
|
||
|
|
@Body() dto: UserAdminUpdateDto,
|
||
|
|
): Promise<UserAdminResponseDto> {
|
||
|
|
return this.service.update(auth, id, dto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Delete(':id')
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
deleteUserAdmin(
|
||
|
|
@Auth() auth: AuthDto,
|
||
|
|
@Param() { id }: UUIDParamDto,
|
||
|
|
@Body() dto: UserAdminDeleteDto,
|
||
|
|
): Promise<UserAdminResponseDto> {
|
||
|
|
return this.service.delete(auth, id, dto);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post(':id/restore')
|
||
|
|
@Authenticated({ admin: true })
|
||
|
|
restoreUserAdmin(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<UserAdminResponseDto> {
|
||
|
|
return this.service.restore(auth, id);
|
||
|
|
}
|
||
|
|
}
|