36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards } from '@nestjs/common';
|
|
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
import { StoreStaffService } from './store-staff.service';
|
|
import { CreateStoreStaffDto, UpdateStoreStaffDto } from './dto/store-staff.dto';
|
|
|
|
@Controller('shop/staff')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class StoreStaffController {
|
|
constructor(private readonly staffService: StoreStaffService) {}
|
|
|
|
@Get()
|
|
list(@CurrentUser() user: AuthUser) {
|
|
return this.staffService.listStaff(user.actorId);
|
|
}
|
|
|
|
@Post()
|
|
create(@CurrentUser() user: AuthUser, @Body() dto: CreateStoreStaffDto) {
|
|
return this.staffService.createStaff(user, dto);
|
|
}
|
|
|
|
@Put(':id')
|
|
update(
|
|
@CurrentUser() user: AuthUser,
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateStoreStaffDto,
|
|
) {
|
|
return this.staffService.updateStaff(user, BigInt(id), dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
|
return this.staffService.deleteStaff(user, BigInt(id));
|
|
}
|
|
}
|