stylist module
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import { Public } from '../auth/decorators/public.decorator';
|
||||
import { Roles } from '../auth/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../auth/guards/roles.guard';
|
||||
import { AuthUser } from '../auth/interfaces/auth-user.interface';
|
||||
import { UserRole } from '../users/enums/user-role.enum';
|
||||
import { CreateStylistDto } from './dto/create-stylist.dto';
|
||||
import { UpdateStylistDto } from './dto/update-stylist.dto';
|
||||
import { StylistsService } from './stylists.service';
|
||||
|
||||
@Controller('stylists')
|
||||
@UseGuards(RolesGuard)
|
||||
export class StylistsController {
|
||||
constructor(private readonly stylistsService: StylistsService) {}
|
||||
|
||||
@Roles(UserRole.ADMIN, UserRole.SALON)
|
||||
@Post()
|
||||
create(
|
||||
@Body() createStylistDto: CreateStylistDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.stylistsService.create(createStylistDto, user);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get()
|
||||
findAll(@Query('salonId', new ParseUUIDPipe({ optional: true })) salonId?: string) {
|
||||
return this.stylistsService.findAll(salonId);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get(':id')
|
||||
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
||||
return this.stylistsService.findOne(id);
|
||||
}
|
||||
|
||||
@Roles(UserRole.ADMIN, UserRole.SALON)
|
||||
@Patch(':id')
|
||||
update(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@Body() updateStylistDto: UpdateStylistDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.stylistsService.update(id, updateStylistDto, user);
|
||||
}
|
||||
|
||||
@Roles(UserRole.ADMIN, UserRole.SALON)
|
||||
@Delete(':id')
|
||||
remove(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.stylistsService.remove(id, user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user