You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.1 KiB
52 lines
1.1 KiB
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
NotFoundException,
|
|
Param,
|
|
ParseIntPipe,
|
|
Post,
|
|
Put,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { Role } from './roles.entity';
|
|
import { RolesService } from './roles.service';
|
|
import {
|
|
ApiBearerAuth,
|
|
ApiImplicitParam,
|
|
ApiResponse,
|
|
ApiUseTags,
|
|
} from '@nestjs/swagger';
|
|
import { RolesDto } from './roles.dto';
|
|
|
|
@ApiUseTags('Role')
|
|
@Controller()
|
|
// @ApiBearerAuth()
|
|
export class RolesController {
|
|
constructor(private readonly rolesService: RolesService) {}
|
|
|
|
@Get()
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'Get a list of all Role.',
|
|
type: Role,
|
|
isArray: true,
|
|
})
|
|
getAll(): Promise<Role[]> {
|
|
return this.rolesService.getAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: 'The Role with the matching id',
|
|
type: Role,
|
|
})
|
|
@ApiResponse({ status: 404, description: 'Not found.' })
|
|
async findOne(@Param('id', new ParseIntPipe()) id: number): Promise<Role> {
|
|
return (await this.rolesService.getOneById(id)).orElseThrow(
|
|
() => new NotFoundException(),
|
|
);
|
|
}
|
|
}
|