Trần Viết Sơn
add branch and branch menu
f97bd0c
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { BranchMenusService } from './branch-menus.service.js';
import { CreateBranchMenuDto } from './dto/create-branch-menu.dto.js';
import { UpdateBranchMenuDto } from './dto/update-branch-menu.dto.js';
import { Public } from '../authentication/authentication.decorator.js';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
@Public()
@Controller('branchs/:branchId/menus')
export class BranchMenusController {
constructor(private readonly branchMenusService: BranchMenusService) {}
@Post() // thêm menu vào branch
create(
@Param('branchId') branchId: string,
@Body() createBranchMenuDto: CreateBranchMenuDto,
) {
return this.branchMenusService.create(branchId, createBranchMenuDto);
}
@Get() // lấy danh sách menu trong branch
findAll(
@Param('branchId') branchId: string,
@Paginate() query: PaginateQuery,
) {
// console.log('branchId', branchId);
return this.branchMenusService.findAll(branchId, query);
}
@Get(':id') // lấy một menu trong branch
findOne(@Param('branchId') branchId: string, @Param('id') id: string) {
return this.branchMenusService.findOne(branchId, id);
}
@Patch(':id')
update(
@Param('id') id: string,
@Body() updateBranchMenuDto: UpdateBranchMenuDto,
) {
return this.branchMenusService.update(+id, updateBranchMenuDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.branchMenusService.remove(+id);
}
}